@gfean/react-native-bundle-drop 0.4.3 → 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.
Files changed (115) hide show
  1. package/BundleDropExpo.podspec +21 -0
  2. package/README.md +250 -124
  3. package/android/src/main/java/com/bundledrop/BundleDropNativePaths.kt +33 -3
  4. package/app.plugin.js +3 -0
  5. package/expo/android/build.gradle +159 -0
  6. package/expo/android/src/main/AndroidManifest.xml +1 -0
  7. package/expo/android/src/main/java/com/bundledrop/expo/BundleDropExpoConfiguration.kt +35 -0
  8. package/expo/android/src/main/java/com/bundledrop/expo/BundleDropExpoIdentityModule.kt +30 -0
  9. package/expo/android/src/main/java/com/bundledrop/expo/BundleDropExpoPackage.kt +29 -0
  10. package/expo/android/src/main/java/com/bundledrop/expo/BundleDropExpoReactNativeHostHandler.kt +16 -0
  11. package/expo/bundle-drop-expo-gradle-plugin/build.gradle +31 -0
  12. package/expo/bundle-drop-expo-gradle-plugin/src/main/groovy/com/bundledrop/gradle/BundleDropExpoPlugin.groovy +83 -0
  13. package/expo/bundle-drop-expo-gradle-plugin/src/main/groovy/com/bundledrop/gradle/GenerateBundleDropBuildIdentityTask.groovy +57 -0
  14. package/expo/ios/Sources/BundleDropExpoIdentity.m +31 -0
  15. package/expo/ios/Sources/BundleDropExpoReactDelegateHandler.swift +24 -0
  16. package/expo-module.config.json +19 -0
  17. package/ios/BundleDropLocator.swift +7 -1
  18. package/lib/CLI/cli.d.ts +1 -2
  19. package/lib/CLI/cli.js +151 -56
  20. package/lib/CLI/logo.js +1 -1
  21. package/lib/CLI/scripts/aipowered/apply-setup-plan.d.ts +12 -0
  22. package/lib/CLI/scripts/aipowered/{apply-plan.js → apply-setup-plan.js} +24 -19
  23. package/lib/CLI/scripts/aipowered/backend-client.d.ts +4 -4
  24. package/lib/CLI/scripts/aipowered/backend-client.js +7 -7
  25. package/lib/CLI/scripts/aipowered/init-project-config.d.ts +17 -0
  26. package/lib/CLI/scripts/aipowered/init-project-config.js +418 -0
  27. package/lib/CLI/scripts/aipowered/scanner.d.ts +10 -3
  28. package/lib/CLI/scripts/aipowered/scanner.js +225 -201
  29. package/lib/CLI/scripts/aipowered/types.d.ts +37 -33
  30. package/lib/CLI/scripts/aipowered/validate-plan.d.ts +9 -2
  31. package/lib/CLI/scripts/aipowered/validate-plan.js +70 -119
  32. package/lib/CLI/scripts/bare-metro-config.d.ts +7 -0
  33. package/lib/CLI/scripts/{init-metro-config.js → bare-metro-config.js} +16 -30
  34. package/lib/CLI/scripts/doctor.d.ts +17 -0
  35. package/lib/CLI/scripts/doctor.js +410 -0
  36. package/lib/CLI/scripts/expo/build-receipt.d.ts +26 -0
  37. package/lib/CLI/scripts/expo/build-receipt.js +223 -0
  38. package/lib/CLI/scripts/expo/configure-expo.d.ts +28 -0
  39. package/lib/CLI/scripts/expo/configure-expo.js +268 -0
  40. package/lib/CLI/scripts/expo/eas-build-proof.d.ts +22 -0
  41. package/lib/CLI/scripts/expo/eas-build-proof.js +116 -0
  42. package/lib/CLI/scripts/expo/package-manager.d.ts +11 -0
  43. package/lib/CLI/scripts/expo/package-manager.js +84 -0
  44. package/lib/CLI/scripts/expo/write-build-receipt.d.ts +25 -0
  45. package/lib/CLI/scripts/expo/write-build-receipt.js +325 -0
  46. package/lib/CLI/scripts/expo/write-eas-build-receipt.d.ts +8 -0
  47. package/lib/CLI/scripts/expo/write-eas-build-receipt.js +71 -0
  48. package/lib/CLI/scripts/init-config.d.ts +18 -1
  49. package/lib/CLI/scripts/init-config.js +29 -8
  50. package/lib/CLI/scripts/login-cli.js +21 -3
  51. package/lib/CLI/scripts/native-setup-contract.d.ts +7 -0
  52. package/lib/CLI/scripts/native-setup-contract.js +101 -0
  53. package/lib/CLI/scripts/post-init.d.ts +6 -1
  54. package/lib/CLI/scripts/post-init.js +6 -33
  55. package/lib/CLI/scripts/upload-cli.d.ts +1 -0
  56. package/lib/CLI/scripts/upload-cli.js +106 -36
  57. package/lib/context.d.ts +0 -2
  58. package/lib/context.js +18 -2
  59. package/lib/expo/buildIdentity.d.ts +15 -0
  60. package/lib/expo/buildIdentity.js +201 -0
  61. package/lib/expo/buildReceipt.d.ts +42 -0
  62. package/lib/expo/buildReceipt.js +272 -0
  63. package/lib/expo/config.d.ts +7 -0
  64. package/lib/expo/config.js +43 -0
  65. package/lib/expo/configCache.d.ts +1 -0
  66. package/lib/expo/configCache.js +20 -0
  67. package/lib/expo/errors.d.ts +6 -0
  68. package/lib/expo/errors.js +11 -0
  69. package/lib/expo/expoUpdatesOwnership.d.ts +13 -0
  70. package/lib/expo/expoUpdatesOwnership.js +22 -0
  71. package/lib/expo/exportExpoProject.d.ts +21 -0
  72. package/lib/expo/exportExpoProject.js +125 -0
  73. package/lib/expo/exportValidation.d.ts +11 -0
  74. package/lib/expo/exportValidation.js +115 -0
  75. package/lib/expo/index.d.ts +18 -0
  76. package/lib/expo/index.js +25 -0
  77. package/lib/expo/localModules.d.ts +4 -0
  78. package/lib/expo/localModules.js +51 -0
  79. package/lib/expo/nativeIdentity.d.ts +1 -0
  80. package/lib/expo/nativeIdentity.js +17 -0
  81. package/lib/expo/projectType.d.ts +7 -0
  82. package/lib/expo/projectType.js +200 -0
  83. package/lib/expo/runtimeVersion.d.ts +13 -0
  84. package/lib/expo/runtimeVersion.js +45 -0
  85. package/lib/expo/types.d.ts +15 -0
  86. package/lib/expo/types.js +2 -0
  87. package/lib/fs/userProperties.d.ts +0 -2
  88. package/lib/fs/userProperties.js +0 -3
  89. package/lib/index.d.ts +1 -1
  90. package/lib/index.js +1 -2
  91. package/lib/loadConfig.d.ts +15 -7
  92. package/lib/loadConfig.js +2 -19
  93. package/lib/metro.d.ts +17 -0
  94. package/lib/metro.js +57 -0
  95. package/lib/native/bundleDropNative.d.ts +2 -0
  96. package/lib/native/bundleDropNative.js +9 -1
  97. package/lib/runtime/service.js +12 -1
  98. package/lib/scripts/bundle.d.ts +2 -2
  99. package/lib/scripts/bundle.js +10 -97
  100. package/lib/scripts/canonicalArtifact.d.ts +30 -0
  101. package/lib/scripts/canonicalArtifact.js +212 -0
  102. package/lib/scripts/exportProject.d.ts +41 -0
  103. package/lib/scripts/exportProject.js +82 -0
  104. package/package.json +51 -46
  105. package/plugin/constants.js +9 -0
  106. package/plugin/expoUpdates.js +131 -0
  107. package/plugin/index.js +11 -0
  108. package/plugin/markers.js +31 -0
  109. package/plugin/withBundleDrop.js +36 -0
  110. package/plugin/xcodeBuildPhase.js +77 -0
  111. package/react-native.config.js +15 -0
  112. package/lib/CLI/scripts/aipowered/apply-plan.d.ts +0 -10
  113. package/lib/CLI/scripts/aipowered/init-native-config.d.ts +0 -2
  114. package/lib/CLI/scripts/aipowered/init-native-config.js +0 -131
  115. package/lib/CLI/scripts/init-metro-config.d.ts +0 -2
package/lib/CLI/cli.js CHANGED
@@ -20,6 +20,11 @@ const DEFAULT_SERVER_URL = 'https://api.bundledrop.app';
20
20
  const DOCS_CLI_URL = 'https://bundledrop.app/docs/cli';
21
21
  const DOCS_UPLOADING_URL = 'https://bundledrop.app/docs/uploading';
22
22
  const DOCS_CI_CD_URL = 'https://bundledrop.app/docs/ci-cd';
23
+ const DOCS_INSTALLATION_URL = 'https://bundledrop.app/docs/installation';
24
+ const setupErrorWithManualInstallation = (error) => {
25
+ const message = error instanceof Error ? error.message : String(error);
26
+ return new Error(`${message}\nManual installation: ${DOCS_INSTALLATION_URL}`);
27
+ };
23
28
  const getTokenPath = () => path_1.default.join(os_1.default.homedir(), '.bundle-drop', 'auth.json');
24
29
  const normalizeServerUrl = (url) => url?.replace(/\/$/, '') || DEFAULT_SERVER_URL;
25
30
  const readStoredAuthData = () => {
@@ -83,13 +88,15 @@ const buildProgram = () => {
83
88
  .version(package_json_1.default.version || '0.0.0', '-v, --cli-version', 'Show CLI version');
84
89
  program.addHelpText('beforeAll', logo);
85
90
  program.addHelpText('before', `
86
- ${chalk_1.default.magentaBright('A blazing-fast OTA delivery system for React Native by GFean.\n')}
91
+ ${chalk_1.default.magentaBright('Ship OTA Updates with Confidence\n')}
87
92
  ${chalk_1.default.bold.cyan('Available Commands:')}
88
93
  `);
89
94
  program.addHelpText('afterAll', `
90
95
  ${chalk_1.default.bold.cyan('Common Usage:')}
91
96
  ${chalk_1.default.gray('bundle-drop login')}
92
97
  ${chalk_1.default.gray('bundle-drop init')}
98
+ ${chalk_1.default.gray('bundle-drop doctor')}
99
+ ${chalk_1.default.gray('bundle-drop doctor --project-type bare --platform android')}
93
100
  ${chalk_1.default.gray('bundle-drop upload android --version 1.2.3 --channel develop')}
94
101
  ${chalk_1.default.gray('bundle-drop upload ios --plist-file ios/Info.plist --channel develop')}
95
102
  ${chalk_1.default.gray('bundle-drop upload android --buildgradle-path android/app/build.gradle --channel develop --release-notes "Fixes"')}
@@ -98,8 +105,7 @@ ${chalk_1.default.gray('Docs →')} ${chalk_1.default.underline.gray(DOCS_CLI_UR
98
105
  ${chalk_1.default.gray('Uploading →')} ${chalk_1.default.underline.gray(DOCS_UPLOADING_URL)}
99
106
  ${chalk_1.default.gray('CI/CD →')} ${chalk_1.default.underline.gray(DOCS_CI_CD_URL)}\n`);
100
107
  program
101
- .command('upload')
102
- .argument('<platform>', chalk_1.default.gray('ios or android'))
108
+ .command('upload <platform>')
103
109
  .option('--plist-file <path>', 'Path to Info.plist for iOS')
104
110
  .option('--version <version>', 'App version. iOS will fallback to --plist-file; Android can fallback to build.gradle when provided.')
105
111
  .option('--buildgradle-path <path>', 'Optional Android build.gradle path to read versionName')
@@ -109,6 +115,7 @@ ${chalk_1.default.gray('CI/CD →')} ${chalk_1.default.underline.gray(DOCS_CI_CD
109
115
  .option('--author <name>', 'Override the author name stored with the bundle')
110
116
  .option('--sourcemap', 'Generate source maps alongside the bundle for error tracking')
111
117
  .option('--artifact-dir <path>', 'Copy bundle, source map, and result JSON to this directory before cleanup')
118
+ .option('--build-receipt <path>', 'Exact local/EAS Expo build identity receipt')
112
119
  .description(chalk_1.default.whiteBright('Bundle and upload an OTA zip to the server'))
113
120
  .addHelpText('after', `
114
121
  ${chalk_1.default.bold('Examples:')}
@@ -138,70 +145,158 @@ ${chalk_1.default.gray('CI/CD docs →')} ${chalk_1.default.underline.gray(DOCS_
138
145
  program
139
146
  .command('login')
140
147
  .description('Log in to the CLI')
141
- .action(() => {
142
- require('../CLI/scripts/login-cli').default();
143
- });
148
+ .action(() => require('../CLI/scripts/login-cli').default());
144
149
  program
145
150
  .command('init')
146
151
  .option('--token <token>', 'Personal Access Token (alternative to `bundle-drop login`)')
147
- .description('Generate bundle.drop.config.js from your logged-in account context')
152
+ .option('--project-type <type>', 'Force project type: expo or bare')
153
+ .option('--dry-run', 'Preview setup and AI context without changing files')
154
+ .option('--migrate-expo-updates', 'Explicitly remove active expo-updates configuration and dependency')
155
+ .option('--prebuild', 'Run a layered Expo prebuild for committed native directories')
156
+ .option('--yes', 'Approve ordinary setup changes noninteractively')
157
+ .description('Configure Bundle Drop for Expo or bare React Native')
148
158
  .action(async (options) => {
149
- if (options.token) {
150
- await require('../CLI/scripts/init-config').initConfig({
151
- serverUrl: normalizeServerUrl(process.env.BUNDLE_DROP_SERVER_URL),
152
- projects: [],
153
- organizations: [],
154
- downloadApiKey: '',
155
- authToken: options.token,
159
+ try {
160
+ if (options.projectType && !['expo', 'bare'].includes(options.projectType)) {
161
+ throw new Error('--project-type must be expo or bare.');
162
+ }
163
+ if (options.token) {
164
+ const { detectProjectType } = require('../expo');
165
+ const projectType = detectProjectType({
166
+ projectRoot: process.cwd(),
167
+ explicitType: options.projectType,
168
+ });
169
+ const serverUrl = normalizeServerUrl(process.env.BUNDLE_DROP_SERVER_URL);
170
+ const tokenContext = await fetchFreshAuthContext({
171
+ serverUrl,
172
+ token: options.token,
173
+ });
174
+ const initConfigModule = require('../CLI/scripts/init-config');
175
+ const hadConfig = initConfigModule.hasExistingBundleDropConfig();
176
+ const configResult = await initConfigModule.initConfig({
177
+ serverUrl,
178
+ projects: tokenContext?.projects || [],
179
+ organizations: tokenContext?.organizations || [],
180
+ downloadApiKey: '',
181
+ authToken: options.token,
182
+ dryRun: true,
183
+ projectType,
184
+ });
185
+ await (0, post_init_1.runPostInitPrompts)({
186
+ ...options,
187
+ projectType,
188
+ ...(!hadConfig && configResult
189
+ ? {
190
+ virtualConfig: {
191
+ content: configResult.content,
192
+ serverUrl: configResult.serverUrl,
193
+ orgSlug: configResult.orgSlug,
194
+ projectSlug: configResult.projectSlug,
195
+ authToken: options.token,
196
+ },
197
+ }
198
+ : {}),
199
+ });
200
+ return;
201
+ }
202
+ const authState = readStoredAuthData();
203
+ if (!authState.exists) {
204
+ console.log('ℹ️ Not logged in. Please run `bundle-drop login` or use --token.\n' +
205
+ `CLI docs: ${DOCS_CLI_URL}\n` +
206
+ `CI/CD docs: ${DOCS_CI_CD_URL}`);
207
+ return;
208
+ }
209
+ if (authState.isInvalid || !authState.data) {
210
+ logInvalidAuthFile();
211
+ return;
212
+ }
213
+ const data = authState.data;
214
+ if (!data.token) {
215
+ logInvalidAuthFile();
216
+ return;
217
+ }
218
+ const { detectProjectType } = require('../expo');
219
+ const projectType = detectProjectType({
220
+ projectRoot: process.cwd(),
221
+ explicitType: options.projectType,
222
+ });
223
+ const serverUrl = normalizeServerUrl(data.serverUrl || data.baseUrl || process.env.BUNDLE_DROP_SERVER_URL);
224
+ const freshContext = await fetchFreshAuthContext({
225
+ serverUrl,
226
+ token: data.token,
227
+ });
228
+ const initData = freshContext ? { ...data, ...freshContext } : data;
229
+ if (freshContext) {
230
+ writeStoredAuthData(authState.tokenPath, initData);
231
+ }
232
+ const initConfigModule = require('../CLI/scripts/init-config');
233
+ const hadConfig = initConfigModule.hasExistingBundleDropConfig();
234
+ const configResult = await initConfigModule.initConfig({
235
+ serverUrl,
236
+ projects: initData.projects || [],
237
+ organizations: initData.organizations || [],
238
+ downloadApiKey: data.downloadApiKey || '',
239
+ authToken: data.token,
240
+ dryRun: true,
241
+ projectType,
242
+ });
243
+ await (0, post_init_1.runPostInitPrompts)({
244
+ ...options,
245
+ projectType,
246
+ ...(!hadConfig && configResult
247
+ ? {
248
+ virtualConfig: {
249
+ content: configResult.content,
250
+ serverUrl: configResult.serverUrl,
251
+ orgSlug: configResult.orgSlug,
252
+ projectSlug: configResult.projectSlug,
253
+ authToken: data.token,
254
+ },
255
+ }
256
+ : {}),
156
257
  });
157
- await (0, post_init_1.runPostInitPrompts)();
158
- return;
159
- }
160
- const authState = readStoredAuthData();
161
- if (!authState.exists) {
162
- console.log('ℹ️ Not logged in. Please run `bundle-drop login` or use --token.\n' +
163
- `CLI docs: ${DOCS_CLI_URL}\n` +
164
- `CI/CD docs: ${DOCS_CI_CD_URL}`);
165
- return;
166
- }
167
- if (authState.isInvalid || !authState.data) {
168
- logInvalidAuthFile();
169
- return;
170
- }
171
- const data = authState.data;
172
- if (!data.token) {
173
- logInvalidAuthFile();
174
- return;
175
258
  }
176
- const serverUrl = normalizeServerUrl(data.serverUrl || data.baseUrl || process.env.BUNDLE_DROP_SERVER_URL);
177
- const freshContext = await fetchFreshAuthContext({
178
- serverUrl,
179
- token: data.token,
180
- });
181
- const initData = freshContext ? { ...data, ...freshContext } : data;
182
- if (freshContext) {
183
- writeStoredAuthData(authState.tokenPath, initData);
259
+ catch (error) {
260
+ throw setupErrorWithManualInstallation(error);
184
261
  }
185
- await require('../CLI/scripts/init-config').initConfig({
186
- serverUrl,
187
- projects: initData.projects || [],
188
- organizations: initData.organizations || [],
189
- downloadApiKey: data.downloadApiKey || '',
190
- authToken: data.token,
191
- });
192
- await (0, post_init_1.runPostInitPrompts)();
193
262
  });
194
263
  program
195
- .command('init-native')
196
- .description('Apply native changes (AppDelegate / MainApplication) automatically')
197
- .action(async () => {
198
- await require('../CLI/scripts/aipowered/init-native-config').initNativeConfigAi();
264
+ .command('doctor')
265
+ .option('--platform <platform>', 'Limit checks to ios or android')
266
+ .option('--project-type <type>', 'Force project type: expo or bare')
267
+ .description('Validate Bundle Drop setup, runtime identity, and OTA startup ownership')
268
+ .addHelpText('after', `
269
+ ${chalk_1.default.bold('Examples:')}
270
+ ${chalk_1.default.gray('bundle-drop doctor')}
271
+ ${chalk_1.default.gray('bundle-drop doctor --platform ios')}
272
+ ${chalk_1.default.gray('bundle-drop doctor --project-type bare --platform android')}
273
+ `)
274
+ .action(async (options) => {
275
+ if (options.platform && !['ios', 'android'].includes(options.platform)) {
276
+ throw new Error('--platform must be ios or android.');
277
+ }
278
+ if (options.projectType && !['expo', 'bare'].includes(options.projectType)) {
279
+ throw new Error('--project-type must be expo or bare.');
280
+ }
281
+ await require('./scripts/doctor').runDoctor(options);
199
282
  });
200
283
  program
201
- .command('init-metro')
202
- .description('Ensure Metro can resolve bundle.drop.config.js via extraNodeModules alias')
203
- .action(() => {
204
- require('../CLI/scripts/init-metro-config').initMetroConfig();
284
+ .command('eas-receipt <platform>')
285
+ .requiredOption('--build-id <id>', 'Exact finished EAS application build ID')
286
+ .option('--output <path>', 'Receipt path; defaults under .bundle-drop')
287
+ .description('Create an authenticated Expo build receipt from official EAS metadata')
288
+ .action(async (platform, options) => {
289
+ if (platform !== 'ios' && platform !== 'android') {
290
+ throw new Error('eas-receipt platform must be ios or android.');
291
+ }
292
+ const receiptPath = await require('./scripts/expo/write-eas-build-receipt')
293
+ .writeEasBuildReceipt({
294
+ projectRoot: process.cwd(),
295
+ platform,
296
+ easBuildId: options.buildId,
297
+ outputPath: options.output,
298
+ });
299
+ console.log(chalk_1.default.green(`EAS build receipt written to ${receiptPath}`));
205
300
  });
206
301
  program
207
302
  .command('whoami')
package/lib/CLI/logo.js CHANGED
@@ -21,6 +21,6 @@ const buildBundleDropLogo = () => {
21
21
  ? exports.BUNDLE_DROP_LOGO_TRUECOLOR
22
22
  : chalk_1.default.cyanBright(exports.BUNDLE_DROP_LOGO_MONO);
23
23
  const title = chalk_1.default.bold.cyanBright(`${figures_1.default.star} React Native Bundle Drop CLI ${figures_1.default.star}`);
24
- return `\n${art}\n${title}`;
24
+ return `\n${art}\n\n${title}`;
25
25
  };
26
26
  exports.buildBundleDropLogo = buildBundleDropLogo;
@@ -0,0 +1,12 @@
1
+ import { AiPatchPlan, AiSetupProjectType } from './types';
2
+ export type SetupApplyResult = {
3
+ projectRoot: string;
4
+ backupDir: string;
5
+ changedFiles: string[];
6
+ };
7
+ export declare function restoreSetupBackups(result: SetupApplyResult): void;
8
+ export declare function applySetupPatchPlans(params: {
9
+ projectRoot: string;
10
+ projectType: AiSetupProjectType;
11
+ changes: AiPatchPlan[];
12
+ }): SetupApplyResult;
@@ -3,48 +3,53 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.restoreBackups = restoreBackups;
7
- exports.applyPatchPlans = applyPatchPlans;
6
+ exports.restoreSetupBackups = restoreSetupBackups;
7
+ exports.applySetupPatchPlans = applySetupPatchPlans;
8
8
  const crypto_1 = __importDefault(require("crypto"));
9
9
  const fs_extra_1 = __importDefault(require("fs-extra"));
10
10
  const path_1 = __importDefault(require("path"));
11
11
  const validate_plan_1 = require("./validate-plan");
12
12
  const sha256 = (content) => crypto_1.default.createHash('sha256').update(content).digest('hex');
13
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);
14
+ const isAllowedSetupFile = (projectType, filePath) => projectType === 'expo'
15
+ ? (0, validate_plan_1.isPatchableExpoConfig)(filePath)
16
+ : (0, validate_plan_1.isPatchableNativeEntrypoint)(filePath);
17
+ function restoreSetupBackups(result) {
18
+ for (const relativePath of result.changedFiles) {
19
+ const backupPath = path_1.default.join(result.backupDir, relativePath);
17
20
  if (fs_extra_1.default.existsSync(backupPath)) {
18
- fs_extra_1.default.copyFileSync(backupPath, path_1.default.resolve(result.backupDir, '..', '..', relative));
21
+ fs_extra_1.default.copyFileSync(backupPath, path_1.default.join(result.projectRoot, relativePath));
19
22
  }
20
23
  }
21
24
  }
22
- function applyPatchPlans(params) {
23
- const backupDir = path_1.default.join(params.projectRoot, '.bundledrop-backup', timestamp());
24
- const changedFiles = [];
25
- const result = { backupDir, changedFiles };
25
+ function applySetupPatchPlans(params) {
26
+ const result = {
27
+ projectRoot: params.projectRoot,
28
+ backupDir: path_1.default.join(params.projectRoot, '.bundledrop-backup', timestamp()),
29
+ changedFiles: [],
30
+ };
26
31
  try {
27
32
  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}`);
33
+ if (!(0, validate_plan_1.isSafeRelativePath)(change.file) || !isAllowedSetupFile(params.projectType, change.file)) {
34
+ throw new Error(`Refusing to write AI setup plan outside its allowlist: ${change.file}`);
30
35
  }
31
36
  const targetPath = path_1.default.join(params.projectRoot, change.file);
32
37
  const original = fs_extra_1.default.readFileSync(targetPath, 'utf8');
33
38
  if (sha256(original) !== change.originalSha256) {
34
- throw new Error(`File changed since AI scan: ${change.file}`);
39
+ throw new Error(`File changed since AI setup scan: ${change.file}`);
35
40
  }
36
- const backupPath = path_1.default.join(backupDir, change.file);
41
+ const backupPath = path_1.default.join(result.backupDir, change.file);
37
42
  fs_extra_1.default.ensureDirSync(path_1.default.dirname(backupPath));
38
43
  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);
44
+ result.changedFiles.push(change.file);
45
+ const temporaryPath = `${targetPath}.bundledrop-tmp`;
46
+ fs_extra_1.default.writeFileSync(temporaryPath, change.updated, 'utf8');
47
+ fs_extra_1.default.renameSync(temporaryPath, targetPath);
43
48
  }
44
49
  return result;
45
50
  }
46
51
  catch (error) {
47
- restoreBackups(result);
52
+ restoreSetupBackups(result);
48
53
  throw error;
49
54
  }
50
55
  }
@@ -1,6 +1,6 @@
1
- import { AiInitPlanRequest, AiInitPlanResponse } from './types';
2
- export declare function requestAiInitPlan(params: {
1
+ import { AiSetupPlanRequest, AiSetupPlanResponse } from './types';
2
+ export declare function requestAiSetupPlan(params: {
3
3
  serverUrl: string;
4
4
  authToken: string;
5
- request: AiInitPlanRequest;
6
- }): Promise<AiInitPlanResponse>;
5
+ request: AiSetupPlanRequest;
6
+ }): Promise<AiSetupPlanResponse>;
@@ -3,16 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.requestAiInitPlan = requestAiInitPlan;
6
+ exports.requestAiSetupPlan = requestAiSetupPlan;
7
7
  const axios_1 = __importDefault(require("axios"));
8
8
  const DEFAULT_AI_INIT_TIMEOUT_MS = 180000;
9
9
  const resolveTimeoutMs = () => {
10
- const value = Number(process.env.BUNDLE_DROP_AI_INIT_TIMEOUT_MS || process.env.AI_INIT_TIMEOUT_MS || '');
10
+ const value = Number(process.env.BUNDLE_DROP_AI_INIT_TIMEOUT_MS || '');
11
11
  return Number.isFinite(value) && value > 0 ? value : DEFAULT_AI_INIT_TIMEOUT_MS;
12
12
  };
13
- async function requestAiInitPlan(params) {
13
+ async function requestAiSetupPlan(params) {
14
14
  try {
15
- const response = await axios_1.default.post(`${params.serverUrl}/ai/init-plan`, params.request, {
15
+ const response = await axios_1.default.post(`${params.serverUrl}/ai/setup-plan`, params.request, {
16
16
  headers: {
17
17
  Accept: 'application/json',
18
18
  Authorization: `Bearer ${params.authToken}`,
@@ -24,11 +24,11 @@ async function requestAiInitPlan(params) {
24
24
  catch (error) {
25
25
  const raw = error?.response?.data;
26
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.');
27
+ throw new Error('AI setup planning timed out. Try again, or increase BUNDLE_DROP_AI_INIT_TIMEOUT_MS.');
28
28
  }
29
29
  const message = raw && typeof raw === 'object'
30
30
  ? raw.error || JSON.stringify(raw)
31
- : raw || error?.message || 'AI planning request failed';
32
- throw new Error(`AI planning request failed: ${message}`);
31
+ : raw || error?.message || 'AI setup planning failed';
32
+ throw new Error(`AI setup planning failed: ${message}`);
33
33
  }
34
34
  }
@@ -0,0 +1,17 @@
1
+ import type { ProjectType } from '../../../expo';
2
+ export type InitProjectOptions = {
3
+ projectType?: ProjectType;
4
+ dryRun?: boolean;
5
+ migrateExpoUpdates?: boolean;
6
+ prebuild?: boolean;
7
+ yes?: boolean;
8
+ virtualConfig?: {
9
+ content: string;
10
+ serverUrl: string;
11
+ orgSlug: string;
12
+ projectSlug: string;
13
+ authToken: string;
14
+ };
15
+ };
16
+ export declare function initProjectConfigAi(options?: InitProjectOptions): Promise<void>;
17
+ export default initProjectConfigAi;