Skip to content

feat(cem): add auro cem command to aggregate component manifests#297

Open
lindseyo1123 wants to merge 2 commits into
feat/context-commandfrom
feat/cem-aggregate
Open

feat(cem): add auro cem command to aggregate component manifests#297
lindseyo1123 wants to merge 2 commits into
feat/context-commandfrom
feat/cem-aggregate

Conversation

@lindseyo1123

@lindseyo1123 lindseyo1123 commented Jul 7, 2026

Copy link
Copy Markdown

Note: Stacked on #296 (adds the #static/* import alias this command relies on). Base will be retargeted to dev once #296 merges. Review the compare against feat/context-command for this PR's isolated diff.

Summary

Adds a new auro cem command that fetches each published Auro component's custom-elements.json from unpkg and merges them into a single aggregated Custom Elements Manifest.

An aggregated manifest gives IDEs, documentation tooling, and AI assistants one machine-readable index of every Auro component's API — props, attributes, slots, CSS parts, and events — instead of 30+ separate files.

Usage

# Write custom-elements.aggregate.json to the current directory
auro cem

# Write to a specific path (e.g. for the docs site to consume)
auro cem --output dist/custom-elements.aggregate.json

Behavior

  • Fetches https://unpkg.com/<pkg>/custom-elements.json for each component in src/static/auroComponents.ts.
  • Components that don't publish a manifest are skipped with a warning (not fatal) — today only a subset of components publish a CEM, so this is expected.
  • Each source module's path is namespaced with its package (e.g. @aurodesignsystem/auro-button/src/auro-button.js) so paths stay unique and every declaration is traceable to its component.

Testing

  • npm run build succeeds (TypeScript typechecks clean).
  • Merge logic verified against real auro-button (7 modules) and auro-card (4 modules) manifests → 11 correctly namespaced modules, valid CEM JSON.
  • Network failures and non-200 responses are handled gracefully with per-package warnings.

Follow-ups

  • Only ~6 components currently publish a CEM; a companion change to the component template (WC-Generator) would broaden coverage.
  • A docs-site CI step could publish the aggregated manifest at a stable URL for consumers.

Summary by Sourcery

Add a CLI command to aggregate Custom Elements Manifests for all published Auro components into a single output file.

New Features:

  • Introduce the auro cem command to fetch and merge Custom Elements Manifests from all configured Auro component packages into one aggregated manifest.

Enhancements:

  • Namespace manifest module paths by package in the aggregated output so declarations remain unique and traceable to their source component.
  • Register the new cem command with the main CLI entrypoint and centralize the list of Auro component packages that publish manifests.

Documentation:

  • Document the auro cem command, its options, and usage examples in the README.

@lindseyo1123
lindseyo1123 requested a review from a team as a code owner July 7, 2026 22:51
@sourcery-ai

sourcery-ai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds a new auro cem CLI command that fetches Custom Elements Manifests for all Auro component packages from unpkg, merges and namespaces their modules into a single aggregated manifest, and writes it to a configurable output file, with robust logging/spinner feedback and non-fatal handling of missing/invalid manifests.

Sequence diagram for auro cem manifest aggregation command

sequenceDiagram
  actor User
  participant auro_cli
  participant Spinner
  participant Unpkg
  participant Logger
  participant Filesystem

  User->>auro_cli: auro cem --output <file>
  auro_cli->>Spinner: ora.start()

  loop AURO_COMPONENT_PACKAGES
    auro_cli->>Unpkg: fetchManifest(pkg)
    alt response_ok_and_valid_json
      Unpkg-->>auro_cli: Manifest
    else request_failed_or_not_ok_or_invalid_json
      Unpkg-->>Logger: Logger.warn(...)
    end
  end

  auro_cli->>auro_cli: mergeManifests(sources)
  auro_cli->>Filesystem: writeFile(outputPath, aggregate)
  alt write_success
    Filesystem-->>Spinner: spinner.succeed(...)
  else write_failure
    Filesystem-->>Spinner: spinner.fail(...)
    Spinner-->>auro_cli: process.exit(1)
  end
Loading

File-Level Changes

Change Details Files
Introduce auro cem CLI command that aggregates per-component Custom Elements Manifests into a single file.
  • Register new cem command in the main CLI entrypoint so it is available as auro cem.
  • Implement manifest fetching from unpkg with graceful handling of network errors, non-200 responses, and invalid JSON, emitting per-package warnings instead of failing the whole command.
  • Implement merge logic that flattens modules from all fetched manifests and namespaces each module path by its originating package while preserving schemaVersion and building a valid aggregated manifest structure.
  • Add CLI options for enabling aggregation and specifying the output file path with sensible defaults and spinner-based progress reporting, including success/failure messages and exit codes.
src/index.ts
src/commands/cem.ts
Define and expose the canonical list of Auro component packages that ship Custom Elements Manifests for use by the aggregation command.
  • Create a static list of @aurodesignsystem component package names documented as the source of manifests for the aggregation command.
  • Export this list as AURO_COMPONENT_PACKAGES for consumption by the cem command implementation.
src/static/auroComponents.ts
Document the new auro cem command, its options, and usage examples in the project README.
  • Add a short description of what the auro cem command does and why it is useful.
  • Document available options, including --output and --aggregate, along with default behaviors.
  • Provide usage examples for generating the aggregated manifest and writing it to a specific path.
README.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

🚀 PR Release Published! @aurodesignsystem-dev/auro-cli@0.0.0-pr297.0 View on npmjs.com

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • The --aggregate option is defined and documented but never read in the command action, so it currently has no effect and could either be removed or wired up to control behavior explicitly.
  • Given that fetchManifest always resolves (returning Manifest | null) and never rejects, Promise.allSettled can be simplified to Promise.all and the result mapping made more direct.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `--aggregate` option is defined and documented but never read in the command action, so it currently has no effect and could either be removed or wired up to control behavior explicitly.
- Given that `fetchManifest` always resolves (returning `Manifest | null`) and never rejects, `Promise.allSettled` can be simplified to `Promise.all` and the result mapping made more direct.

## Individual Comments

### Comment 1
<location path="src/commands/cem.ts" line_range="87" />
<code_context>
+  .description(
+    "Aggregate the Custom Elements Manifests of all published Auro components into a single file",
+  )
+  .option("--aggregate", "Fetch and merge every component manifest", true)
+  .option(
+    "-o, --output <file>",
</code_context>
<issue_to_address>
**issue (bug_risk):** The `--aggregate` option is defined but not used anywhere in the action handler.

Currently `--aggregate` has no effect; manifests are always aggregated. If you intend to support a non-aggregate mode, branch on `options.aggregate`. Otherwise, remove the option to prevent user confusion.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/commands/cem.ts Outdated
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

🚀 PR Release Published! @aurodesignsystem-dev/auro-cli@0.0.0-pr297.1 View on npmjs.com

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

🚀 PR Release Published! @aurodesignsystem-dev/auro-cli@0.0.0-pr297.2 View on npmjs.com

Adds 'auro cem' which fetches each published Auro component's
custom-elements.json from unpkg and merges them into a single aggregated
Custom Elements Manifest. Components that don't publish a manifest are
skipped with a warning. Source module paths are namespaced by package so
consumers can trace each declaration to its component.

Produces one machine-readable API index for IDEs, docs tooling, and AI
assistants.

- src/static/auroComponents.ts: list of component packages to aggregate
- src/commands/cem.ts: the command (--output, --aggregate)
- registers the command and documents it in the README
Addresses review feedback on the cem aggregation command:
- Deep-namespace internal module references (exports' declaration.module,
  references, etc.), not just the top-level module path, so the merged
  manifest's internal references stay valid. External references (those with
  a package) are left untouched.
- Distinguish genuine 404s (component has no CEM yet) from transient
  network/5xx failures; exit non-zero when the aggregate is incomplete due to
  transient errors so CI can retry.
- Defer skip messages until after the spinner so output isn't garbled.
- Warn on mixed CEM schema versions.
- Drop the no-op --aggregate flag and the empty readme field.
- Correct the component-list doc comment (not all components publish a CEM).
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

🚀 PR Release Published! @aurodesignsystem-dev/auro-cli@0.0.0-pr297.3 View on npmjs.com

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.

1 participant