-
Notifications
You must be signed in to change notification settings - Fork 1.2k
functions:kits:list #10935
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?
functions:kits:list #10935
Changes from all commits
6bbff41
37c63e2
94f1dcc
ee09043
dad8f0e
ac35e00
433ac64
02584c8
e2f7502
ce205f8
1ee065d
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,27 @@ | ||||||||||||||||||||||||||||
| import { requireConfig } from "../requireConfig"; | ||||||||||||||||||||||||||||
| import { Command } from "../command"; | ||||||||||||||||||||||||||||
| import { listKitConfigs } from "../functions/kits/config"; | ||||||||||||||||||||||||||||
| import { Options } from "../options"; | ||||||||||||||||||||||||||||
| import { logLabeledBullet } from "../utils"; | ||||||||||||||||||||||||||||
| import { logger } from "../logger"; | ||||||||||||||||||||||||||||
| import * as Table from "cli-table3"; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| export const command = new Command("functions:kits:list") | ||||||||||||||||||||||||||||
| .description("list all the kits that are installed in your firebase.json") | ||||||||||||||||||||||||||||
| .before(requireConfig) | ||||||||||||||||||||||||||||
| .action((options: Options) => { | ||||||||||||||||||||||||||||
| const firebaseConfig = options.config; | ||||||||||||||||||||||||||||
| const validatedConfig = firebaseConfig.src; | ||||||||||||||||||||||||||||
| const kitConfigs = listKitConfigs(validatedConfig); | ||||||||||||||||||||||||||||
|
Comment on lines
+12
to
+15
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the command is run outside of a Firebase project directory,
Suggested change
References
|
||||||||||||||||||||||||||||
| if (kitConfigs.length < 1) { | ||||||||||||||||||||||||||||
| logLabeledBullet("functions", `there are no kits in firebase.json`); | ||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const table = new Table({ head: ["Kit", "Instances"], style: { head: ["yellow"] } }); | ||||||||||||||||||||||||||||
| for (const kitConfig of kitConfigs) { | ||||||||||||||||||||||||||||
| const instanceIds = Object.keys(kitConfig.instances); | ||||||||||||||||||||||||||||
| table.push([kitConfig.kit, instanceIds.join(", ")]); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| logger.info(table.toString()); | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,10 @@ | ||||||||||||||||||||||||
| import { FirebaseConfig } from "../../firebaseConfig"; | ||||||||||||||||||||||||
| import { ValidatedKitSingle, normalizeAndValidate, isKitConfig } from "../projectConfig"; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||
| * Extracts only the Kit configs from a parsed Firebase.json. | ||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||
| export function listKitConfigs(config: FirebaseConfig): ValidatedKitSingle[] { | ||||||||||||||||||||||||
| const normalized = normalizeAndValidate(config.functions); | ||||||||||||||||||||||||
| return normalized.filter((s) => isKitConfig(s)); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
Comment on lines
+7
to
+10
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If
Suggested change
References
|
||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import
FirebaseErrorto handle the case where the command is run outside of a Firebase project directory.