Skip to content

fix(extensions): include emitted events in ext:info output - #11098

Open
Noxtimo wants to merge 1 commit into
firebase:mainfrom
Noxtimo:fix/ext-info-mention-events
Open

Noxtimo wants to merge 1 commit into
firebase:mainfrom
Noxtimo:fix/ext-info-mention-events

Conversation

@Noxtimo

@Noxtimo Noxtimo commented Sep 17, 2026

Copy link
Copy Markdown

Description

In ext:info, extension specifications declaring custom Eventarc events under spec.events were omitted from both Markdown and terminal output formats. This caused automated README documentation generated via firebase ext:info --markdown to lack emitted event documentation. This change formats and displays the Events Emitted: section whenever spec.events is present on the extension specification.

Fixes #8209

Scenarios Tested

  • Added unit tests in src/commands/ext-info.spec.ts verifying Events Emitted: header and event details are rendered for --markdown and terminal modes.
  • Verified event types render cleanly when descriptions are missing or empty without trailing colons.
  • Verified no event section is rendered when spec.events is omitted or empty.
  • Ran npx mocha src/commands/ext-info.spec.ts (4 passing).
  • Ran npx mocha src/extensions/*.spec.ts (401 passing).
  • Ran npm run test:compile (clean exit).
  • Ran npx prettier --check and npx eslint on modified files.

Sample Commands

  • firebase ext:info firestore-bigquery-export --markdown
  • firebase ext:info ./my-extension

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the ext:info command to include emitted events in its output, accompanied by comprehensive unit tests and a changelog entry. The feedback suggests two improvements: explicitly verifying that spec.events is an array using Array.isArray() to prevent runtime errors, and refactoring the event string construction to use a single conditional template literal instead of string concatenation for better readability.

Comment thread src/commands/ext-info.ts
lines.push(`* ${resource.name} (${resource.type})`);
}
}
if (spec.events && spec.events.length > 0) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To prevent potential runtime errors or unexpected output (such as printing * undefined) if spec.events is malformed (e.g., parsed as a string or object instead of an array), we should explicitly verify that spec.events is an array using Array.isArray(), similar to how spec.params is checked on line 75.

Suggested change
if (spec.events && spec.events.length > 0) {
if (spec.events && Array.isArray(spec.events) && spec.events.length > 0) {
References
  1. Use strict null checks and handle undefined/null explicitly. (link)

Comment thread src/commands/ext-info.ts
if (spec.events && spec.events.length > 0) {
lines.push("", "**Events Emitted:**");
for (const event of spec.events) {
lines.push(`* ${event.type}` + (event.description ? `: ${event.description}` : ""));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using string concatenation (+) with template literals can be less readable. We can simplify this by using a single template literal with a conditional expression, or by splitting it into a cleaner conditional template literal.

Suggested change
lines.push(`* ${event.type}` + (event.description ? `: ${event.description}` : ""));
lines.push(event.description ? `* ${event.type}: ${event.description}` : `* ${event.type}`);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

firebase ext:info doesn't mention events

2 participants