@gfean/react-native-bundle-drop 0.2.2 → 0.3.3

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 (37) hide show
  1. package/BundleDrop.podspec +2 -1
  2. package/LICENSE +15 -0
  3. package/README.md +122 -238
  4. package/lib/CLI/cli.d.ts +2 -1
  5. package/lib/CLI/cli.js +154 -131
  6. package/lib/CLI/scripts/init-config.js +12 -5
  7. package/lib/CLI/scripts/init-native-config.d.ts +16 -0
  8. package/lib/CLI/scripts/init-native-config.js +28 -9
  9. package/lib/CLI/scripts/login-cli.d.ts +71 -0
  10. package/lib/CLI/scripts/login-cli.js +24 -13
  11. package/lib/CLI/scripts/post-init.js +9 -3
  12. package/lib/CLI/scripts/upload-cli.js +14 -7
  13. package/lib/api/types.d.ts +29 -0
  14. package/lib/index.d.ts +16 -4
  15. package/lib/index.js +25 -15
  16. package/lib/manager/downloadAndInstall.d.ts +2 -0
  17. package/lib/manager/reporting.js +3 -0
  18. package/lib/manager/updateCheck.d.ts +13 -0
  19. package/lib/manager/updateCheck.js +6 -0
  20. package/lib/manager/updateState.d.ts +2 -0
  21. package/lib/manager/updateState.js +10 -4
  22. package/lib/runtime/initState.d.ts +48 -0
  23. package/lib/runtime/initState.js +131 -0
  24. package/lib/runtime/service.d.ts +111 -0
  25. package/lib/runtime/service.js +537 -0
  26. package/lib/scripts/bundle.d.ts +13 -1
  27. package/lib/scripts/bundle.js +126 -115
  28. package/lib/scripts/download-bundle.d.ts +4 -1
  29. package/lib/scripts/download-bundle.js +41 -33
  30. package/lib/scripts/upload-bundle.d.ts +7 -1
  31. package/lib/scripts/upload-bundle.js +183 -175
  32. package/lib/useBundleDrop.d.ts +19 -9
  33. package/lib/useBundleDrop.js +26 -172
  34. package/package.json +59 -8
  35. package/CLIENT_README.md +0 -381
  36. package/lib/manager/initUpdateManager.d.ts +0 -10
  37. package/lib/manager/initUpdateManager.js +0 -137
package/lib/CLI/cli.js CHANGED
@@ -4,16 +4,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.buildProgram = void 0;
7
8
  const chalk_1 = __importDefault(require("chalk"));
8
9
  const commander_1 = require("commander");
9
10
  const figures_1 = __importDefault(require("figures"));
11
+ const fs_1 = __importDefault(require("fs"));
12
+ const os_1 = __importDefault(require("os"));
13
+ const path_1 = __importDefault(require("path"));
10
14
  const upload_cli_1 = __importDefault(require("./scripts/upload-cli"));
11
15
  const post_init_1 = require("./scripts/post-init");
12
16
  const package_json_1 = __importDefault(require("../../package.json"));
13
- const program = new commander_1.Command();
14
- program
15
- .name('bundle-drop')
16
- .version(package_json_1.default.version || '0.0.0', '-v, --cli-version', 'Show CLI version');
17
17
  const logo = chalk_1.default.cyanBright(`
18
18
  ______ ______
19
19
  |_ _ \\ |_ _ \`.
@@ -22,12 +22,45 @@ const logo = chalk_1.default.cyanBright(`
22
22
  _| |__) |_| |_.' /
23
23
  |_______/|______.'
24
24
  `) + chalk_1.default.bold.cyanBright(`\n${figures_1.default.star} React Native Bundle Drop CLI ${figures_1.default.star}`);
25
- program.addHelpText('beforeAll', logo);
26
- program.addHelpText('before', `
25
+ const DEFAULT_SERVER_URL = 'https://api.bundledrop.app';
26
+ const DOCS_CLI_URL = 'https://bundledrop.app/docs/cli';
27
+ const DOCS_UPLOADING_URL = 'https://bundledrop.app/docs/uploading';
28
+ const DOCS_CI_CD_URL = 'https://bundledrop.app/docs/ci-cd';
29
+ const getTokenPath = () => path_1.default.join(os_1.default.homedir(), '.bundle-drop', 'auth.json');
30
+ const normalizeServerUrl = (url) => url?.replace(/\/$/, '') || DEFAULT_SERVER_URL;
31
+ const readStoredAuthData = () => {
32
+ const tokenPath = getTokenPath();
33
+ if (!fs_1.default.existsSync(tokenPath)) {
34
+ return { tokenPath, exists: false, data: null, isInvalid: false };
35
+ }
36
+ try {
37
+ const raw = fs_1.default.readFileSync(tokenPath, 'utf-8');
38
+ const parsed = JSON.parse(raw);
39
+ if (!parsed || typeof parsed !== 'object') {
40
+ throw new Error('Invalid auth payload');
41
+ }
42
+ return { tokenPath, exists: true, data: parsed, isInvalid: false };
43
+ }
44
+ catch {
45
+ return { tokenPath, exists: true, data: null, isInvalid: true };
46
+ }
47
+ };
48
+ const logInvalidAuthFile = () => {
49
+ console.log('❌ Failed to read CLI auth session. Please run `bundle-drop login` again or use --token.\n' +
50
+ `CLI docs: ${DOCS_CLI_URL}\n` +
51
+ `CI/CD docs: ${DOCS_CI_CD_URL}`);
52
+ };
53
+ const buildProgram = () => {
54
+ const program = new commander_1.Command();
55
+ program
56
+ .name('bundle-drop')
57
+ .version(package_json_1.default.version || '0.0.0', '-v, --cli-version', 'Show CLI version');
58
+ program.addHelpText('beforeAll', logo);
59
+ program.addHelpText('before', `
27
60
  ${chalk_1.default.magentaBright('A blazing-fast OTA delivery system for React Native by GFean.\n')}
28
61
  ${chalk_1.default.bold.cyan('Available Commands:')}
29
62
  `);
30
- program.addHelpText('afterAll', `
63
+ program.addHelpText('afterAll', `
31
64
  ${chalk_1.default.bold.cyan('Common Usage:')}
32
65
  ${chalk_1.default.gray('bundle-drop login')}
33
66
  ${chalk_1.default.gray('bundle-drop init')}
@@ -35,138 +68,128 @@ ${chalk_1.default.bold.cyan('Common Usage:')}
35
68
  ${chalk_1.default.gray('bundle-drop upload ios --plist-file ios/Info.plist --channel General')}
36
69
  ${chalk_1.default.gray('bundle-drop upload android --buildgradle-path android/app/build.gradle --channel General --release-notes "Fixes"')}
37
70
 
38
- ${chalk_1.default.gray('Need help? →')} ${chalk_1.default.underline.gray('https://github.com/GFean/react-native-bundle-drop')}\n`);
39
- // ------------------------
40
- // Commands
41
- // ------------------------
42
- program
43
- .command('upload')
44
- .argument('<platform>', chalk_1.default.gray('ios or android'))
45
- .option('--plist-file <path>', 'Path to Info.plist for iOS')
46
- .option('--version <version>', 'App version. iOS will fallback to --plist-file; Android can fallback to build.gradle when provided.')
47
- .option('--buildgradle-path <path>', 'Optional Android build.gradle path to read versionName')
48
- .option('--channel <name>', 'Target channel name to associate the bundle') // ← ADD THIS LINE
49
- .option('--runtimeVersion <runtimeVersion>', 'Override runtimeVersion from metadata/config')
50
- .option('--release-notes <text>', 'Release notes (max 2000 chars)')
51
- .option('--token <token>', 'Personal Access Token (alternative to `bundle-drop login`)')
52
- .option('--author <name>', 'Override the author name stored with the bundle')
53
- .description(chalk_1.default.whiteBright('Bundle and upload an OTA zip to the server'))
54
- .addHelpText('after', `
71
+ ${chalk_1.default.gray('Docs →')} ${chalk_1.default.underline.gray(DOCS_CLI_URL)}
72
+ ${chalk_1.default.gray('Uploading →')} ${chalk_1.default.underline.gray(DOCS_UPLOADING_URL)}
73
+ ${chalk_1.default.gray('CI/CD →')} ${chalk_1.default.underline.gray(DOCS_CI_CD_URL)}\n`);
74
+ program
75
+ .command('upload')
76
+ .argument('<platform>', chalk_1.default.gray('ios or android'))
77
+ .option('--plist-file <path>', 'Path to Info.plist for iOS')
78
+ .option('--version <version>', 'App version. iOS will fallback to --plist-file; Android can fallback to build.gradle when provided.')
79
+ .option('--buildgradle-path <path>', 'Optional Android build.gradle path to read versionName')
80
+ .option('--channel <name>', 'Target channel name to associate the bundle')
81
+ .option('--runtimeVersion <runtimeVersion>', 'Override runtimeVersion from metadata/config')
82
+ .option('--release-notes <text>', 'Release notes (max 2000 chars)')
83
+ .option('--token <token>', 'Personal Access Token (alternative to `bundle-drop login`)')
84
+ .option('--author <name>', 'Override the author name stored with the bundle')
85
+ .description(chalk_1.default.whiteBright('Bundle and upload an OTA zip to the server'))
86
+ .addHelpText('after', `
55
87
  ${chalk_1.default.bold('Examples:')}
56
88
  ${chalk_1.default.gray('bundle-drop upload android --version 1.2.3 --channel General')}
57
89
  ${chalk_1.default.gray('bundle-drop upload ios --plist-file ios/Info.plist --channel General')}
58
90
  ${chalk_1.default.gray('bundle-drop upload android --buildgradle-path android/app/build.gradle --channel QA --release-notes "Bug fixes"')}
59
91
  ${chalk_1.default.gray('bundle-drop upload android --version 1.2.3 --channel General --runtimeVersion 3.0.0')}
60
92
  ${chalk_1.default.gray('bundle-drop upload android --version 1.2.3 --channel General --token bdp_pat_xxx')}
93
+
94
+ ${chalk_1.default.gray('Uploading docs →')} ${chalk_1.default.underline.gray(DOCS_UPLOADING_URL)}
95
+ ${chalk_1.default.gray('CI/CD docs →')} ${chalk_1.default.underline.gray(DOCS_CI_CD_URL)}
61
96
  `)
62
- .action(upload_cli_1.default);
63
- program
64
- .command('logout')
65
- .description('Log out of the CLI')
66
- .action(() => {
67
- //eslint-disable-next-line
68
- const fs = require('fs');
69
- //eslint-disable-next-line
70
- const path = require('path');
71
- //eslint-disable-next-line
72
- const os = require('os');
73
- const tokenPath = path.join(os.homedir(), '.bundle-drop', 'auth.json');
74
- if (fs.existsSync(tokenPath)) {
75
- fs.unlinkSync(tokenPath);
76
- console.log('🚪 Logged out.');
77
- }
78
- else {
79
- console.log('ℹ️ Not logged in.');
80
- }
81
- });
82
- program
83
- .command('login')
84
- .description('Log in to the CLI')
85
- .action(() => {
86
- //eslint-disable-next-line
87
- require('../CLI/scripts/login-cli').default();
88
- });
89
- program
90
- .command('init')
91
- .option('--token <token>', 'Personal Access Token (alternative to `bundle-drop login`)')
92
- .description('Generate bundle.drop.config.js from your logged-in account context')
93
- .action(async (options) => {
94
- //eslint-disable-next-line
95
- const fs = require('fs');
96
- //eslint-disable-next-line
97
- const path = require('path');
98
- //eslint-disable-next-line
99
- const os = require('os');
100
- if (options.token) {
101
- const serverUrl = process.env.BUNDLE_DROP_SERVER_URL?.replace(/\/$/, '') ||
102
- 'https://api.bundledrop.app';
103
- //eslint-disable-next-line
97
+ .action(upload_cli_1.default);
98
+ program
99
+ .command('logout')
100
+ .description('Log out of the CLI')
101
+ .action(() => {
102
+ const tokenPath = getTokenPath();
103
+ if (fs_1.default.existsSync(tokenPath)) {
104
+ fs_1.default.unlinkSync(tokenPath);
105
+ console.log('🚪 Logged out.');
106
+ }
107
+ else {
108
+ console.log('ℹ️ Not logged in.');
109
+ }
110
+ });
111
+ program
112
+ .command('login')
113
+ .description('Log in to the CLI')
114
+ .action(() => {
115
+ require('../CLI/scripts/login-cli').default();
116
+ });
117
+ program
118
+ .command('init')
119
+ .option('--token <token>', 'Personal Access Token (alternative to `bundle-drop login`)')
120
+ .description('Generate bundle.drop.config.js from your logged-in account context')
121
+ .action(async (options) => {
122
+ if (options.token) {
123
+ await require('../CLI/scripts/init-config').initConfig({
124
+ serverUrl: normalizeServerUrl(process.env.BUNDLE_DROP_SERVER_URL),
125
+ projects: [],
126
+ organizations: [],
127
+ downloadApiKey: '',
128
+ authToken: options.token,
129
+ });
130
+ await (0, post_init_1.runPostInitPrompts)();
131
+ return;
132
+ }
133
+ const authState = readStoredAuthData();
134
+ if (!authState.exists) {
135
+ console.log('ℹ️ Not logged in. Please run `bundle-drop login` or use --token.\n' +
136
+ `CLI docs: ${DOCS_CLI_URL}\n` +
137
+ `CI/CD docs: ${DOCS_CI_CD_URL}`);
138
+ return;
139
+ }
140
+ if (authState.isInvalid || !authState.data) {
141
+ logInvalidAuthFile();
142
+ return;
143
+ }
144
+ const data = authState.data;
145
+ if (!data.token) {
146
+ logInvalidAuthFile();
147
+ return;
148
+ }
104
149
  await require('../CLI/scripts/init-config').initConfig({
105
- serverUrl,
106
- projects: [],
107
- organizations: [],
108
- downloadApiKey: '',
109
- authToken: options.token,
150
+ serverUrl: normalizeServerUrl(data.serverUrl || data.baseUrl || process.env.BUNDLE_DROP_SERVER_URL),
151
+ projects: data.projects || [],
152
+ organizations: data.organizations || [],
153
+ downloadApiKey: data.downloadApiKey || '',
154
+ authToken: data.token,
110
155
  });
111
156
  await (0, post_init_1.runPostInitPrompts)();
112
- return;
113
- }
114
- const tokenPath = path.join(os.homedir(), '.bundle-drop', 'auth.json');
115
- if (!fs.existsSync(tokenPath)) {
116
- console.log('ℹ️ Not logged in. Please run `bundle-drop login` or use --token.');
117
- return;
118
- }
119
- const data = JSON.parse(fs.readFileSync(tokenPath, 'utf-8'));
120
- const projects = data.projects || [];
121
- const organizations = data.organizations || [];
122
- const downloadApiKey = data.downloadApiKey || '';
123
- const token = data.token;
124
- const serverUrl = data.serverUrl ||
125
- data.baseUrl ||
126
- process.env.BUNDLE_DROP_SERVER_URL?.replace(/\/$/, '') ||
127
- 'https://api.bundledrop.app';
128
- //eslint-disable-next-line
129
- await require('../CLI/scripts/init-config').initConfig({
130
- serverUrl,
131
- projects,
132
- organizations,
133
- downloadApiKey,
134
- authToken: token,
135
157
  });
136
- await (0, post_init_1.runPostInitPrompts)();
137
- });
138
- program
139
- .command('init-native')
140
- .description('Attempt to apply native changes (AppDelegate / MainApplication) automatically')
141
- .action(() => {
142
- //eslint-disable-next-line
143
- require('../CLI/scripts/init-native-config').initNativeConfig();
144
- });
145
- program
146
- .command('init-metro')
147
- .description('Ensure Metro can resolve bundle.drop.config.js via extraNodeModules alias')
148
- .action(() => {
149
- //eslint-disable-next-line
150
- require('../CLI/scripts/init-metro-config').initMetroConfig();
151
- });
152
- program
153
- .command('whoami')
154
- .description('Show currently logged in user')
155
- .action(() => {
156
- //eslint-disable-next-line
157
- const fs = require('fs');
158
- //eslint-disable-next-line
159
- const path = require('path');
160
- //eslint-disable-next-line
161
- const os = require('os');
162
- const tokenPath = path.join(os.homedir(), '.bundle-drop', 'auth.json');
163
- if (fs.existsSync(tokenPath)) {
164
- const data = fs.readFileSync(tokenPath, 'utf-8');
165
- const { user } = JSON.parse(data);
166
- console.log(`👤 Logged in as: ${chalk_1.default.cyan(user.firstName + ' ' + user.lastName)} <${user.email}>`);
167
- }
168
- else {
169
- console.log('ℹ️ Not logged in.');
170
- }
171
- });
172
- program.parse();
158
+ program
159
+ .command('init-native')
160
+ .description('Attempt to apply native changes (AppDelegate / MainApplication) automatically')
161
+ .action(() => {
162
+ require('../CLI/scripts/init-native-config').initNativeConfig();
163
+ });
164
+ program
165
+ .command('init-metro')
166
+ .description('Ensure Metro can resolve bundle.drop.config.js via extraNodeModules alias')
167
+ .action(() => {
168
+ require('../CLI/scripts/init-metro-config').initMetroConfig();
169
+ });
170
+ program
171
+ .command('whoami')
172
+ .description('Show currently logged in user')
173
+ .action(() => {
174
+ const authState = readStoredAuthData();
175
+ if (!authState.exists) {
176
+ console.log('ℹ️ Not logged in.');
177
+ return;
178
+ }
179
+ const user = authState.data?.user;
180
+ if (authState.isInvalid ||
181
+ !user ||
182
+ !user.firstName ||
183
+ !user.lastName ||
184
+ !user.email) {
185
+ logInvalidAuthFile();
186
+ return;
187
+ }
188
+ console.log(`👤 Logged in as: ${chalk_1.default.cyan(`${user.firstName} ${user.lastName}`)} <${user.email}>`);
189
+ });
190
+ return program;
191
+ };
192
+ exports.buildProgram = buildProgram;
193
+ if (require.main === module) {
194
+ (0, exports.buildProgram)().parse();
195
+ }
@@ -11,6 +11,8 @@ const chalk_1 = __importDefault(require("chalk"));
11
11
  const fs_extra_1 = __importDefault(require("fs-extra"));
12
12
  const path_1 = __importDefault(require("path"));
13
13
  const prompts_1 = __importDefault(require("prompts"));
14
+ const DOCS_PROJECT_CREATION_URL = 'https://bundledrop.app/docs/project-creation';
15
+ const DOCS_INSTALLATION_URL = 'https://bundledrop.app/docs/installation';
14
16
  function normalizeServerUrl(url) {
15
17
  return url.replace(/\/$/, '');
16
18
  }
@@ -28,7 +30,8 @@ async function fetchProjectCredentials(params) {
28
30
  return res.data || null;
29
31
  }
30
32
  catch (err) {
31
- console.log(chalk_1.default.yellow(`⚠️ Failed to fetch project credentials from ${url}. Please verify login and project access.`));
33
+ console.log(chalk_1.default.yellow(`⚠️ Failed to fetch project credentials from ${url}. Please verify login and project access.\n` +
34
+ `If the project is not set up yet, see ${DOCS_PROJECT_CREATION_URL}`));
32
35
  return null;
33
36
  }
34
37
  }
@@ -55,14 +58,16 @@ function hasExistingBundleDropConfig(startDir = process.cwd()) {
55
58
  async function initConfig(params) {
56
59
  const configPath = getBundleDropConfigPath();
57
60
  if (fs_extra_1.default.existsSync(configPath)) {
58
- console.log(chalk_1.default.yellow(`ℹ️ bundle.drop.config.js already exists at ${configPath}. If this is accidental, delete it and rerun the init/login.`));
61
+ console.log(chalk_1.default.yellow(`ℹ️ bundle.drop.config.js already exists at ${configPath}. If this is accidental, delete it and rerun the init/login.\n` +
62
+ `See ${DOCS_INSTALLATION_URL}`));
59
63
  return;
60
64
  }
61
65
  let orgSlug = '';
62
66
  let project = null;
63
67
  // Org selection
64
68
  if (!params.organizations || params.organizations.length === 0) {
65
- console.log(chalk_1.default.yellow('⚠️ No organizations returned; org slug will be left blank.'));
69
+ console.log(chalk_1.default.yellow(`⚠️ No organizations returned; org slug will be left blank.\n` +
70
+ `Create an organization first: ${DOCS_PROJECT_CREATION_URL}`));
66
71
  }
67
72
  else if (params.organizations.length === 1) {
68
73
  orgSlug = params.organizations[0].slug;
@@ -85,7 +90,8 @@ async function initConfig(params) {
85
90
  }
86
91
  // Project selection
87
92
  if (!params.projects?.length) {
88
- console.log(chalk_1.default.red('⚠️ No projects returned; project values will be left blank.'));
93
+ console.log(chalk_1.default.red(`⚠️ No projects returned; project values will be left blank.\n` +
94
+ `Create a project first: ${DOCS_PROJECT_CREATION_URL}`));
89
95
  }
90
96
  else if (params.projects.length === 1) {
91
97
  project = params.projects[0];
@@ -125,7 +131,8 @@ async function initConfig(params) {
125
131
  apiKey = credentials.downloadApiKey;
126
132
  }
127
133
  else if (!apiKey) {
128
- console.log(chalk_1.default.yellow('⚠️ No project API key returned from /projects/:projectSlug/credentials; config will be created without apiKey.'));
134
+ console.log(chalk_1.default.yellow('⚠️ No project API key returned from /projects/:projectSlug/credentials; config will be created without apiKey.\n' +
135
+ `See ${DOCS_INSTALLATION_URL}`));
129
136
  }
130
137
  }
131
138
  else if (projectSlug && !params.authToken && !apiKey) {
@@ -1,2 +1,18 @@
1
+ export declare function findProjectRoot(startDir: string): string;
2
+ export declare function findFileByName(root: string, fileName: string): string | null;
3
+ /**
4
+ * Starting from an opening brace at `openIndex`, count balanced braces
5
+ * and return the index *after* the matching closing brace.
6
+ * Returns -1 if unbalanced.
7
+ */
8
+ export declare function findMatchingBrace(content: string, openIndex: number): number;
9
+ export declare function ensureImport(content: string, importLine: string): string;
10
+ export declare function patchAndroidMainApplicationKotlin(filePath: string): void;
11
+ export declare function ensureJavaImport(content: string, importLine: string): string;
12
+ export declare function patchAndroidMainApplicationJava(filePath: string): void;
13
+ export declare function patchAndroidMainApplication(filePath: string): void;
14
+ export declare function patchIosAppDelegateSwift(filePath: string): void;
15
+ export declare function patchIosAppDelegateObjc(filePath: string): void;
16
+ export declare function patchIosAppDelegate(filePath: string): void;
1
17
  export declare function initNativeConfig(): Promise<void>;
2
18
  export default initNativeConfig;
@@ -3,11 +3,25 @@ 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.findProjectRoot = findProjectRoot;
7
+ exports.findFileByName = findFileByName;
8
+ exports.findMatchingBrace = findMatchingBrace;
9
+ exports.ensureImport = ensureImport;
10
+ exports.patchAndroidMainApplicationKotlin = patchAndroidMainApplicationKotlin;
11
+ exports.ensureJavaImport = ensureJavaImport;
12
+ exports.patchAndroidMainApplicationJava = patchAndroidMainApplicationJava;
13
+ exports.patchAndroidMainApplication = patchAndroidMainApplication;
14
+ exports.patchIosAppDelegateSwift = patchIosAppDelegateSwift;
15
+ exports.patchIosAppDelegateObjc = patchIosAppDelegateObjc;
16
+ exports.patchIosAppDelegate = patchIosAppDelegate;
6
17
  exports.initNativeConfig = initNativeConfig;
7
18
  const chalk_1 = __importDefault(require("chalk"));
8
19
  const fs_extra_1 = __importDefault(require("fs-extra"));
9
20
  const path_1 = __importDefault(require("path"));
10
21
  const prompts_1 = __importDefault(require("prompts"));
22
+ const DOCS_INSTALLATION_URL = 'https://bundledrop.app/docs/installation';
23
+ const DOCS_ANDROID_NATIVE_SETUP_URL = `${DOCS_INSTALLATION_URL}#android-mainapplication`;
24
+ const DOCS_IOS_NATIVE_SETUP_URL = `${DOCS_INSTALLATION_URL}#ios-appdelegate`;
11
25
  function findProjectRoot(startDir) {
12
26
  let dir = path_1.default.resolve(startDir);
13
27
  const MAX_UP = 12;
@@ -215,7 +229,8 @@ function patchAndroidMainApplicationKotlin(filePath) {
215
229
  }
216
230
  else {
217
231
  console.log(chalk_1.default.yellow(` ⚠️ Could not find a suitable insertion point in ${filePath}.\n` +
218
- ` Please add the reactNativeHost + reactHost blocks manually (see CLIENT_README.md).`));
232
+ ` Please add the reactNativeHost + reactHost blocks manually.\n` +
233
+ ` See ${DOCS_ANDROID_NATIVE_SETUP_URL}`));
219
234
  return;
220
235
  }
221
236
  }
@@ -234,7 +249,8 @@ function patchAndroidMainApplicationKotlin(filePath) {
234
249
  }
235
250
  // 4. No recognizable template
236
251
  console.log(chalk_1.default.yellow(` ⚠️ Could not detect a supported MainApplication template in ${filePath}.\n` +
237
- ` Please add the BundleDrop override manually. See CLIENT_README.md section "Native setup (Android)".`));
252
+ ` Please add the BundleDrop override manually.\n` +
253
+ ` See ${DOCS_ANDROID_NATIVE_SETUP_URL}`));
238
254
  }
239
255
  // ---------------------------------------------------------------------------
240
256
  // Android MainApplication.java patcher (older RN versions)
@@ -285,7 +301,8 @@ function patchAndroidMainApplicationJava(filePath) {
285
301
  }
286
302
  }
287
303
  console.log(chalk_1.default.yellow(` ⚠️ Found getJSBundleFile() but could not safely parse its body.\n` +
288
- ` Please replace the method body manually. See CLIENT_README.md section "Native setup (Android)".`));
304
+ ` Please replace the method body manually.\n` +
305
+ ` See ${DOCS_ANDROID_NATIVE_SETUP_URL}`));
289
306
  return;
290
307
  }
291
308
  // 3. Has ReactNativeHost anonymous class — inject getJSBundleFile() inside it
@@ -325,12 +342,14 @@ function patchAndroidMainApplicationJava(filePath) {
325
342
  }
326
343
  }
327
344
  console.log(chalk_1.default.yellow(` ⚠️ Found ReactNativeHost but could not safely parse its anonymous class.\n` +
328
- ` Please add getJSBundleFile() override manually. See CLIENT_README.md section "Native setup (Android)".`));
345
+ ` Please add getJSBundleFile() override manually.\n` +
346
+ ` See ${DOCS_ANDROID_NATIVE_SETUP_URL}`));
329
347
  return;
330
348
  }
331
349
  // 4. No recognizable template
332
350
  console.log(chalk_1.default.yellow(` ⚠️ Could not detect a supported MainApplication template in ${filePath}.\n` +
333
- ` Please add the BundleDrop override manually. See CLIENT_README.md section "Native setup (Android)".`));
351
+ ` Please add the BundleDrop override manually.\n` +
352
+ ` See ${DOCS_ANDROID_NATIVE_SETUP_URL}`));
334
353
  }
335
354
  function patchAndroidMainApplication(filePath) {
336
355
  const ext = path_1.default.extname(filePath);
@@ -343,7 +362,7 @@ function patchAndroidMainApplication(filePath) {
343
362
  }
344
363
  else {
345
364
  console.log(chalk_1.default.yellow(` ⚠️ Unsupported MainApplication file type (${ext}). Please patch manually.\n` +
346
- ` See CLIENT_README.md section "Native setup (Android)".`));
365
+ ` See ${DOCS_ANDROID_NATIVE_SETUP_URL}`));
347
366
  }
348
367
  }
349
368
  // ---------------------------------------------------------------------------
@@ -420,7 +439,7 @@ function patchIosAppDelegateSwift(filePath) {
420
439
  fs_extra_1.default.writeFileSync(filePath, content, 'utf8');
421
440
  console.log(chalk_1.default.yellow(` ⚠️ Could not find bundleURL() override in ${filePath}.\n` +
422
441
  ` Please add manually: Debug → Metro, Release → BundleDropLocator.bundleURL() fallback to main.jsbundle.\n` +
423
- ` See CLIENT_README.md section "Native setup (iOS)".`));
442
+ ` See ${DOCS_IOS_NATIVE_SETUP_URL}`));
424
443
  }
425
444
  function patchIosAppDelegateObjc(filePath) {
426
445
  let content = fs_extra_1.default.readFileSync(filePath, 'utf8');
@@ -460,7 +479,7 @@ function patchIosAppDelegateObjc(filePath) {
460
479
  fs_extra_1.default.writeFileSync(filePath, content, 'utf8');
461
480
  console.log(chalk_1.default.yellow(` ⚠️ Could not find sourceURLForBridge: in ${filePath}.\n` +
462
481
  ` Please locate the method that returns the JS bundle URL and apply the Release OTA fallback.\n` +
463
- ` See CLIENT_README.md section "Native setup (iOS)".`));
482
+ ` See ${DOCS_IOS_NATIVE_SETUP_URL}`));
464
483
  }
465
484
  function patchIosAppDelegate(filePath) {
466
485
  const ext = path_1.default.extname(filePath);
@@ -473,7 +492,7 @@ function patchIosAppDelegate(filePath) {
473
492
  }
474
493
  else {
475
494
  console.log(chalk_1.default.yellow(` ⚠️ Unsupported AppDelegate file type (${ext}). Please patch manually.\n` +
476
- ` See CLIENT_README.md section "Native setup (iOS)".`));
495
+ ` See ${DOCS_IOS_NATIVE_SETUP_URL}`));
477
496
  }
478
497
  }
479
498
  async function initNativeConfig() {
@@ -1,2 +1,73 @@
1
+ import { IncomingMessage, ServerResponse } from 'http';
2
+ type CliSessionResponse = {
3
+ sessionId: string;
4
+ state: string;
5
+ authorizeUrl: string;
6
+ expiresAt: string;
7
+ };
8
+ type Project = {
9
+ name: string;
10
+ slug: string;
11
+ orgId: string;
12
+ };
13
+ type Org = {
14
+ slug: string;
15
+ orgId: string;
16
+ name: string;
17
+ };
18
+ type CliExchangeResponse = {
19
+ token: string;
20
+ email: string;
21
+ firstName: string;
22
+ lastName: string;
23
+ projects?: Project[];
24
+ organizations?: Org[];
25
+ memberships?: unknown[];
26
+ downloadApiKey?: string;
27
+ };
28
+ type CallbackPayload = {
29
+ sessionId: string;
30
+ state: string;
31
+ exchangeCode: string;
32
+ };
33
+ type AuthFilePayload = {
34
+ token: string;
35
+ user: {
36
+ email: string;
37
+ firstName: string;
38
+ lastName: string;
39
+ };
40
+ projects: Project[];
41
+ organizations: Org[];
42
+ memberships: unknown[];
43
+ downloadApiKey: string;
44
+ serverUrl: string;
45
+ };
46
+ export declare const getBaseUrl: () => string;
47
+ export declare const getClientName: () => string;
48
+ export declare const openBrowser: (url: string) => Promise<void>;
49
+ export declare const writeAuthFile: ({ payload, serverUrl, }: {
50
+ payload: CliExchangeResponse;
51
+ serverUrl: string;
52
+ }) => Promise<AuthFilePayload>;
53
+ export declare const respondJson: (res: ServerResponse, statusCode: number, body: Record<string, unknown>) => void;
54
+ export declare const readJsonBody: (req: IncomingMessage) => Promise<string>;
55
+ export declare const createLoginSession: ({ baseUrl, clientName, callbackUrl, }: {
56
+ baseUrl: string;
57
+ clientName: string;
58
+ callbackUrl: string;
59
+ }) => Promise<CliSessionResponse>;
60
+ export declare const exchangeSession: ({ baseUrl, payload, }: {
61
+ baseUrl: string;
62
+ payload: CallbackPayload;
63
+ }) => Promise<CliExchangeResponse>;
64
+ export declare const waitForExchangeWithTimeout: (exchangePromise: Promise<CliExchangeResponse>) => Promise<CliExchangeResponse>;
65
+ export declare const startCallbackServer: ({ baseUrl, }: {
66
+ baseUrl: string;
67
+ }) => Promise<{
68
+ callbackUrl: string;
69
+ waitForExchange: () => Promise<CliExchangeResponse>;
70
+ close: () => Promise<void>;
71
+ }>;
1
72
  declare const login: () => Promise<void>;
2
73
  export default login;