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 +21 -0
- package/README.md +414 -0
- package/bin/rn-firebase.mjs +2 -0
- package/dist/cli.js +5311 -0
- package/package.json +72 -0
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
|
+
[](https://www.npmjs.com/package/rn-firebase-cli)
|
|
8
|
+
[](https://www.npmjs.com/package/rn-firebase-cli)
|
|
9
|
+
[](LICENSE)
|
|
10
|
+
[](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>
|