rn-firebase-cli 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tharun Poongavanam
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,414 @@
1
+ <div align="center">
2
+
3
+ # πŸ”₯ rn-firebase-cli
4
+
5
+ **One command. Three platforms. Zero Firebase setup headache.**
6
+
7
+ [![npm version](https://img.shields.io/npm/v/rn-firebase-cli.svg?style=flat-square)](https://www.npmjs.com/package/rn-firebase-cli)
8
+ [![npm downloads](https://img.shields.io/npm/dm/rn-firebase-cli.svg?style=flat-square)](https://www.npmjs.com/package/rn-firebase-cli)
9
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](LICENSE)
10
+ [![Node β‰₯18](https://img.shields.io/badge/node-%3E%3D18-brightgreen?style=flat-square)](https://nodejs.org)
11
+
12
+ Configure Firebase for **Android, iOS, and Web** in your React Native & Expo project β€” automatically.
13
+
14
+ ```bash
15
+ npx rn-firebase-cli setup
16
+ ```
17
+
18
+ </div>
19
+
20
+ ---
21
+
22
+ ## πŸ“– Table of Contents
23
+
24
+ - [Why rn-firebase?](#-why-rn-firebase)
25
+ - [Install](#-install)
26
+ - [Quick Start](#-quick-start)
27
+ - [Commands](#-commands)
28
+ - [How It Works](#-how-it-works)
29
+ - [Platform Support](#-platform-support)
30
+ - [Doctor & Fix](#-doctor--fix)
31
+ - [Safety Principles](#-safety-principles)
32
+ - [Development](#-development)
33
+ - [Roadmap](#-roadmap)
34
+ - [Contributing](#-contributing)
35
+ - [License](#-license)
36
+
37
+ ---
38
+
39
+ ## ✨ Why rn-firebase?
40
+
41
+ Setting up Firebase in a React Native or Expo project is tedious:
42
+
43
+ - Download `google-services.json` β†’ drop it in the right folder
44
+ - Patch `android/build.gradle` and `android/app/build.gradle`
45
+ - Download `GoogleService-Info.plist` β†’ place it in the Xcode target folder
46
+ - Generate `firebaseConfig.ts` for web
47
+ - Register apps in Firebase Console for each platform
48
+ - Install `@react-native-firebase/app`, run `expo prebuild`, …
49
+
50
+ **`rn-firebase` automates all of that** from a single interactive CLI that talks directly to the Firebase API on your behalf.
51
+
52
+ ```
53
+ Your React Native / Expo project
54
+ β”‚
55
+ β–Ό
56
+ rn-firebase
57
+ β”‚
58
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”
59
+ β–Ό β–Ό β–Ό
60
+ Android iOS Web
61
+ β”‚ β”‚ β”‚
62
+ β””β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”˜
63
+ β–Ό
64
+ Firebase Ready πŸ”₯
65
+ ```
66
+
67
+ ---
68
+
69
+ ## πŸ“¦ Install
70
+
71
+ ### Use without installing (recommended)
72
+
73
+ ```bash
74
+ npx rn-firebase-cli setup
75
+ # or
76
+ bunx rn-firebase-cli setup
77
+ ```
78
+
79
+ ### Install globally
80
+
81
+ ```bash
82
+ # npm
83
+ npm install -g rn-firebase-cli
84
+
85
+ # bun
86
+ bun add -g rn-firebase-cli
87
+
88
+ # pnpm
89
+ pnpm add -g rn-firebase-cli
90
+ ```
91
+
92
+ ### Prerequisites
93
+
94
+ | Requirement | Purpose |
95
+ |---|---|
96
+ | [Firebase CLI](https://firebase.google.com/docs/cli) | API access β€” `npm i -g firebase-tools` |
97
+ | `firebase login` | Authenticate before running setup |
98
+ | Node.js β‰₯ 18 | Runtime |
99
+
100
+ ---
101
+
102
+ ## πŸš€ Quick Start
103
+
104
+ From the root of your React Native or Expo project:
105
+
106
+ ```bash
107
+ npx rn-firebase setup
108
+ ```
109
+
110
+ The CLI auto-detects your project and guides you through every step:
111
+
112
+ ```
113
+ πŸ”₯ Firebase Setup CLI for React Native / Expo
114
+
115
+ βœ” Project analyzed
116
+ Project type: Expo project
117
+ Package manager: bun
118
+ Android: found Β· iOS: found
119
+
120
+ βœ” Firebase CLI v15.8.0 found
121
+ βœ” Authenticated as you@example.com
122
+
123
+ ? Select a Firebase project to connect: β€Ί my-awesome-app
124
+ ? Which platforms do you want to configure? β€Ί β—‰ Android β—‰ iOS β—‰ Web
125
+
126
+ β—† Configuring Android
127
+ βœ” Android app registered with Firebase
128
+ βœ” Android configuration files installed
129
+ βœ” Gradle configuration updated with Google Services plugin
130
+
131
+ β—† Configuring iOS
132
+ βœ” iOS app registered with Firebase
133
+ βœ” iOS configuration files installed
134
+
135
+ β—† Configuring Web
136
+ βœ” Web configuration created at src/firebaseConfig.ts
137
+
138
+ β—† Dependency Management
139
+ βœ” All required Firebase dependencies are already installed
140
+
141
+ πŸŽ‰ Firebase configuration complete!
142
+ ```
143
+
144
+ ---
145
+
146
+ ## 🧩 Commands
147
+
148
+ | Command | Description |
149
+ |---|---|
150
+ | `rn-firebase setup` | Interactive Firebase setup wizard |
151
+ | `rn-firebase doctor` | Diagnose configuration issues (read-only) |
152
+ | `rn-firebase fix` | Auto-fix all detected problems |
153
+ | `rn-firebase fix android` | Fix Android configuration only |
154
+ | `rn-firebase fix ios` | Fix iOS configuration only |
155
+ | `rn-firebase fix web` | Fix Web configuration only |
156
+ | `rn-firebase fix deps` | Install missing Firebase dependencies |
157
+ | `rn-firebase --help` | Show help |
158
+ | `rn-firebase --version` | Show version |
159
+
160
+ ---
161
+
162
+ ## 🧠 How It Works
163
+
164
+ ### 1 Β· Project Detection
165
+
166
+ `rn-firebase` inspects your project before touching anything:
167
+
168
+ - **Project type** β€” Expo managed, bare React Native, or plain JS/TS
169
+ - **Package manager** β€” Bun, npm, pnpm, or Yarn (detected via lockfile)
170
+ - **Native folders** β€” `android/` and `ios/` presence
171
+ - **Package / bundle IDs** β€” from `app.json`, `build.gradle`, `AndroidManifest.xml`, or `.pbxproj`
172
+ - **Existing Firebase files** β€” `google-services.json`, `GoogleService-Info.plist`, `firebaseConfig.ts`
173
+ - **Installed dependencies** β€” `@react-native-firebase/app`, `firebase`
174
+
175
+ ### 2 Β· Expo Prebuild (if needed)
176
+
177
+ For Expo projects without native folders:
178
+
179
+ ```
180
+ Native projects are missing.
181
+ ? Run expo prebuild now? β€Ί Yes
182
+ ```
183
+
184
+ Runs `expo prebuild --no-install` so your native projects are ready for configuration.
185
+
186
+ ### 3 Β· Firebase Auth & Project Selection
187
+
188
+ Uses the Firebase CLI you already authenticated with (`firebase login`). Prompts you to select an existing project or create a new one.
189
+
190
+ ### 4 Β· Per-Platform Configuration
191
+
192
+ #### Android
193
+
194
+ - Registers Android app in Firebase (or finds existing one)
195
+ - Downloads `google-services.json` β†’ places it in `android/app/`
196
+ - Patches `android/build.gradle` to add the Google Services classpath (inside `buildscript {}` only)
197
+ - Applies `com.google.gms.google-services` plugin in `android/app/build.gradle`
198
+ - Updates `app.json` for Expo projects
199
+
200
+ #### iOS
201
+
202
+ - Registers iOS app in Firebase (or finds existing one)
203
+ - Downloads `GoogleService-Info.plist` β†’ places it in the correct Xcode target folder
204
+ - Updates `app.json` for Expo projects
205
+
206
+ #### Web
207
+
208
+ - Registers Web app in Firebase (or finds existing one)
209
+ - Downloads the Web SDK config
210
+ - Generates `src/firebaseConfig.ts` (or `.js` for non-TS projects)
211
+
212
+ ### 5 Β· Dependency Management
213
+
214
+ Checks which Firebase packages are missing and offers to install them using your project's package manager:
215
+
216
+ ```
217
+ Missing dependencies: @react-native-firebase/app
218
+ ? Install missing dependencies using bun? β€Ί Yes
219
+ ```
220
+
221
+ ---
222
+
223
+ ## πŸ“± Platform Support
224
+
225
+ | Feature | Android | iOS | Web |
226
+ |---|:---:|:---:|:---:|
227
+ | Auto-detect app ID / bundle ID | βœ… | βœ… | β€” |
228
+ | Firebase app registration | βœ… | βœ… | βœ… |
229
+ | Config file download & placement | βœ… | βœ… | βœ… |
230
+ | Gradle patching | βœ… | β€” | β€” |
231
+ | Expo `app.json` integration | βœ… | βœ… | βœ… |
232
+ | Doctor | βœ… | βœ… | βœ… |
233
+ | Fix | βœ… | βœ… | βœ… |
234
+
235
+ ---
236
+
237
+ ## 🩺 Doctor & Fix
238
+
239
+ ### Doctor β€” read-only health check
240
+
241
+ ```bash
242
+ rn-firebase doctor
243
+ ```
244
+
245
+ ```
246
+ πŸ”₯ Firebase Doctor
247
+
248
+ Project
249
+ βœ” Expo project
250
+ βœ” Firebase CLI installed (v15.8.0)
251
+ βœ” Firebase authenticated
252
+
253
+ Android
254
+ βœ” google-services.json present
255
+ βœ” Package ID: com.example.myapp
256
+
257
+ iOS
258
+ βœ” GoogleService-Info.plist present
259
+ βœ” Bundle ID: com.example.myapp
260
+
261
+ Web
262
+ βœ— Firebase Web configuration missing
263
+
264
+ Dependencies
265
+ βœ” @react-native-firebase/app
266
+
267
+ 1 issue detected.
268
+ Run: rn-firebase fix web
269
+ ```
270
+
271
+ ### Fix β€” targeted remediation
272
+
273
+ ```bash
274
+ rn-firebase fix # fix everything
275
+ rn-firebase fix android # Android only
276
+ rn-firebase fix ios # iOS only
277
+ rn-firebase fix web # Web only
278
+ rn-firebase fix deps # missing packages only
279
+ ```
280
+
281
+ Before making any changes, the CLI shows a preview and asks for confirmation.
282
+
283
+ ---
284
+
285
+ ## πŸ›‘οΈ Safety Principles
286
+
287
+ - **No passwords** β€” relies solely on `firebase login` OAuth flow
288
+ - **No silent overwrites** β€” existing `google-services.json` and `GoogleService-Info.plist` are backed up as `.bak` before replacement
289
+ - **Confirmation prompts** β€” destructive operations always ask first
290
+ - **No shell injection** β€” all subprocess calls use `shell: false` with validated arguments
291
+ - **Path traversal protection** β€” paths from `app.json` are validated to stay inside the project directory
292
+ - **Idempotent** β€” running `setup` twice doesn't duplicate Gradle plugins or Expo config entries
293
+ - **Temp file cleanup** β€” sensitive SDK credential files downloaded to `.tmp-*` are always deleted in `finally` blocks
294
+
295
+ ---
296
+
297
+ ## πŸ—οΈ Architecture
298
+
299
+ ```
300
+ src/
301
+ β”œβ”€β”€ cli.ts Commander.js entrypoint
302
+ β”œβ”€β”€ commands/
303
+ β”‚ β”œβ”€β”€ setup.ts Interactive setup wizard
304
+ β”‚ β”œβ”€β”€ doctor.ts Read-only diagnostics
305
+ β”‚ └── fix.ts Auto-remediation
306
+ β”œβ”€β”€ detection/
307
+ β”‚ β”œβ”€β”€ project.ts Aggregates all detections β†’ ProjectInfo
308
+ β”‚ β”œβ”€β”€ platforms.ts Android/iOS native dir + config file detection
309
+ β”‚ β”œβ”€β”€ package-manager.ts Lockfile-based PM detection
310
+ β”‚ └── dependencies.ts package.json dep scanning
311
+ β”œβ”€β”€ expo/
312
+ β”‚ β”œβ”€β”€ prebuild.ts expo prebuild runner
313
+ β”‚ └── plugins.ts app.json updater
314
+ β”œβ”€β”€ firebase/
315
+ β”‚ β”œβ”€β”€ cli.ts Firebase CLI wrapper + JSON extractor
316
+ β”‚ β”œβ”€β”€ auth.ts Auth check via firebase login:list
317
+ β”‚ β”œβ”€β”€ projects.ts Projects list/create
318
+ β”‚ └── apps.ts Apps list/create/sdkconfig
319
+ β”œβ”€β”€ config/
320
+ β”‚ β”œβ”€β”€ android.ts google-services.json + Gradle patcher
321
+ β”‚ β”œβ”€β”€ ios.ts GoogleService-Info.plist placer
322
+ β”‚ └── web.ts firebaseConfig.ts generator
323
+ └── utils/
324
+ β”œβ”€β”€ exec.ts runCommandSync / runCommandAsync (shell: false)
325
+ └── fs.ts Safe file I/O helpers
326
+ ```
327
+
328
+ ---
329
+
330
+ ## πŸ§ͺ Development
331
+
332
+ ```bash
333
+ # Clone
334
+ git clone https://github.com/tharunpoongavanam/rn-firebase-cli.git
335
+ cd rn-firebase-cli
336
+
337
+ # Install
338
+ bun install
339
+
340
+ # Run locally in your RN/Expo project directory
341
+ bun run src/cli.ts setup
342
+ bun run src/cli.ts doctor
343
+
344
+ # Tests (29 tests across 5 suites)
345
+ bun test
346
+
347
+ # Build for distribution
348
+ bun run build
349
+ ```
350
+
351
+ ### Running tests
352
+
353
+ ```bash
354
+ bun test
355
+ ```
356
+
357
+ ```
358
+ βœ“ Firebase CLI output parsing β€Ί extracts JSON when CLI prints progress logs
359
+ βœ“ Command execution security β€Ί sanitizeArg rejects shell metacharacters
360
+ βœ“ Project Detection β€Ί rejects path traversal attempts in app.json
361
+ βœ“ Platform Configurations β€Ί inserts classpath only inside buildscript block
362
+ βœ“ Platform Configurations β€Ί creates a .bak backup before overwriting credentials
363
+ ... 29 tests pass
364
+ ```
365
+
366
+ ---
367
+
368
+ ## πŸ—ΊοΈ Roadmap
369
+
370
+ - [x] Project detection (Expo, bare RN, package manager)
371
+ - [x] Firebase auth & project selection
372
+ - [x] Android configuration (google-services.json + Gradle)
373
+ - [x] iOS configuration (GoogleService-Info.plist)
374
+ - [x] Web configuration (firebaseConfig.ts)
375
+ - [x] Smart dependency management
376
+ - [x] Doctor command
377
+ - [x] Fix command (all / per-platform)
378
+ - [x] Security hardening (path traversal, shell injection, credential backups)
379
+ - [ ] `--dry-run` mode (preview changes without writing files)
380
+ - [ ] `--ci` mode (non-interactive, exit code for CI pipelines)
381
+ - [ ] `rn-firebase setup --platform android` (skip platform selection)
382
+ - [ ] `rn-firebase doctor --json` (machine-readable output)
383
+ - [ ] Firebase Emulator Suite integration
384
+ - [ ] Multi-project / multi-environment support
385
+
386
+ ---
387
+
388
+ ## 🀝 Contributing
389
+
390
+ Contributions are welcome!
391
+
392
+ 1. Fork the repository
393
+ 2. Create a feature branch: `git checkout -b feat/my-feature`
394
+ 3. Make your changes and add tests
395
+ 4. Ensure all tests pass: `bun test`
396
+ 5. Open a pull request describing what changed and why
397
+
398
+ For large changes, please open an issue first to discuss the approach.
399
+
400
+ ---
401
+
402
+ ## πŸ“„ License
403
+
404
+ [MIT](LICENSE) Β© [Tharun Poongavanam](https://github.com/THARUN-BART)
405
+
406
+ ---
407
+
408
+ <div align="center">
409
+
410
+ **[npm](https://www.npmjs.com/package/rn-firebase-cli)** Β· **[GitHub](https://github.com/tharunpoongavanam/rn-firebase-cli)** Β· **[Issues](https://github.com/tharunpoongavanam/rn-firebase-cli/issues)**
411
+
412
+ Made with ❀️ for the React Native community
413
+
414
+ </div>
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import '../dist/cli.js';