-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat(crashlytics): add crashlytics:onboard:web command
#10861
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
024e485
9d8f182
e3063fb
e6c369b
1e93749
e2f9456
b193b64
15fd548
bfc087d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - Added `crashlytics:onboard:web` CLI command to support Crashlytics onboarding for web apps. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| import { Command } from "../command"; | ||
| import { FirebaseError } from "../error"; | ||
| import { logger } from "../logger"; | ||
| import { | ||
| AppPlatform, | ||
| checkForApps, | ||
| listFirebaseApps, | ||
| selectAppInteractively, | ||
| } from "../management/apps"; | ||
| import { needProjectId } from "../projectUtils"; | ||
| import { requireAuth } from "../requireAuth"; | ||
| import { onboardCrashlyticsWeb, OnboardWebResult } from "../crashlytics/onboarding"; | ||
| import { Options } from "../options"; | ||
|
|
||
| export interface CrashlyticsOnboardOptions extends Options { | ||
| app?: string; | ||
| } | ||
|
|
||
| export const command = new Command("crashlytics:onboard:web [appId]") | ||
| .description("onboard a Firebase web app to Crashlytics") | ||
| .option("--app <appID>", "the app id of your Firebase app") | ||
| .before(requireAuth) | ||
| .action( | ||
| async ( | ||
| appIdInput = "", | ||
| options: CrashlyticsOnboardOptions, | ||
| ): Promise<OnboardWebResult | undefined> => { | ||
| const projectId = needProjectId(options); | ||
| let appId = appIdInput || options.app || ""; | ||
|
|
||
| let appPlatform: AppPlatform = AppPlatform.ANY; | ||
| if (!appId) { | ||
| const apps = await listFirebaseApps(projectId, AppPlatform.ANY); | ||
| checkForApps(apps, AppPlatform.ANY); | ||
| if (apps.length === 1) { | ||
| appId = apps[0].appId; | ||
| appPlatform = apps[0].platform; | ||
| } else if (options.nonInteractive) { | ||
| throw new FirebaseError( | ||
| `Project ${projectId} has multiple apps, must specify an app id.`, | ||
| ); | ||
| } else { | ||
| const appMetadata = await selectAppInteractively(apps, AppPlatform.ANY); | ||
| appId = appMetadata.appId; | ||
| appPlatform = appMetadata.platform; | ||
| } | ||
| } else { | ||
| const apps = await listFirebaseApps(projectId, AppPlatform.ANY); | ||
| const matchedApp = apps.find((a) => a.appId === appId); | ||
| if (matchedApp) { | ||
| appPlatform = matchedApp.platform; | ||
| } else if (appId.includes(":web:")) { | ||
|
Check warning on line 52 in src/commands/crashlytics-onboard-web.ts
|
||
| appPlatform = AppPlatform.WEB; | ||
| } else if (appId.includes(":android:")) { | ||
|
Check warning on line 54 in src/commands/crashlytics-onboard-web.ts
|
||
| appPlatform = AppPlatform.ANDROID; | ||
| } else if (appId.includes(":ios:")) { | ||
|
Check warning on line 56 in src/commands/crashlytics-onboard-web.ts
|
||
| appPlatform = AppPlatform.IOS; | ||
| } | ||
| } | ||
|
|
||
| if (appPlatform !== AppPlatform.WEB && !appId.includes(":web:")) { | ||
|
Check warning on line 61 in src/commands/crashlytics-onboard-web.ts
|
||
| logger.info( | ||
| `Crashlytics onboarding via the CLI is currently only supported for Web apps. No onboarding steps needed for non-Web app: ${appId}`, | ||
| ); | ||
| return undefined; | ||
| } | ||
|
|
||
| return await onboardCrashlyticsWeb(projectId, appId, options); | ||
| }, | ||
| ); | ||
Uh oh!
There was an error while loading. Please reload this page.