Skip to content
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

feat(build): new script that generate extended component files for wca to be able to analyze #85 #86

Merged

Conversation

sun-mota
Copy link
Contributor

@sun-mota sun-mota commented Nov 4, 2024

Alaska Airlines Pull Request

#85

This PR is to create new script that generate extended component files for wca to be able to analyze

Tested on Auro-flight
This change is a part of AlaskaAirlines/auro-flight#139

By submitting this Pull Request, I confirm that my contribution is made under the terms of the Apache 2.0 license and I have performed a self-review of my own update.

Summary by Sourcery

Add a new build script to generate extended component files for wca analysis, facilitating the analysis of components by creating necessary files automatically.

New Features:

  • Introduce a new script to generate extended component files for wca analysis.

Build:

  • Add a script extendedComponentWriter.mjs to automate the creation of extended component files for wca.

@sun-mota sun-mota requested a review from a team as a code owner November 4, 2024 15:02
@sun-mota sun-mota self-assigned this Nov 4, 2024
Copy link

sourcery-ai bot commented Nov 4, 2024

Reviewer's Guide by Sourcery

This PR introduces a new build script that generates extended component files specifically for Web Component Analyzer (WCA) analysis. The implementation consists of two main files: a script to process and write the extended components, and a template generator for the extended component code.

Class diagram for extended component generation script

classDiagram
    class ExtendedComponentWriter {
        +globPath(sources)
        +createExtendsFile(filePaths)
        +main()
    }
    class ExtendedComponentTemplate {
        +default(code, sourcePath)
    }
    ExtendedComponentWriter --> ExtendedComponentTemplate : uses
    note for ExtendedComponentWriter "Handles file processing and writing"
    note for ExtendedComponentTemplate "Generates extended component code"
Loading

File-Level Changes

Change Details Files
Implementation of the extended component writer script
  • Creates a directory for WCA analysis files if it doesn't exist
  • Uses glob patterns to find component files that need to be processed
  • Reads each source file and generates an extended version in the WCA directory
  • Implements error handling for file operations and glob pattern processing
  • Processes command-line arguments to determine which files to analyze
scripts/build/extendedComponentWriter.mjs
Creation of the extended component template generator
  • Extracts component name and class name using regex patterns
  • Generates a new class that extends the original component
  • Creates a custom element registration if it doesn't already exist
  • Maintains proper import references to the original component
scripts/build/extendedComponentTemplate.mjs

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.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a 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. You can also use
    this command to specify where the summary should be inserted.

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

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @sun-mota - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider making the regex patterns in extendedComponentTemplate.mjs more robust and add error messaging for when they don't match the expected patterns
  • Error handling approach is inconsistent between functions - globPath() re-throws while createExtendsFile() fails silently. Consider standardizing the error handling approach
Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

scripts/build/extendedComponentTemplate.mjs Outdated Show resolved Hide resolved
scripts/build/extendedComponentWriter.mjs Outdated Show resolved Hide resolved
@sun-mota
Copy link
Contributor Author

sun-mota commented Nov 4, 2024

@sourcery-ai review

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @sun-mota - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider enhancing error handling with more specific error messages and context, especially in createExtendsFile() for file operations.
  • The regex patterns in extendedComponentTemplate.mjs could be more robust - consider adding validation for extracted values and handling edge cases where the patterns don't match.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

scripts/build/extendedComponentTemplate.mjs Outdated Show resolved Hide resolved
Copy link
Contributor

@jordanjones243 jordanjones243 left a comment

Choose a reason for hiding this comment

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

I think your file names should be a little more specific. Saying "Component Writer" and Component Template" does not really tell me what these files are used for.

scripts/build/extendedComponentTemplate.mjs Outdated Show resolved Hide resolved
@sun-mota sun-mota force-pushed the sun/extended-component-writer/85 branch from b37d58a to 6fff53c Compare November 4, 2024 16:28
@sun-mota sun-mota changed the base branch from main to dhook/update-processDocs-arguments November 4, 2024 18:55
@sun-mota sun-mota force-pushed the sun/extended-component-writer/85 branch from 610d4c3 to 038dc93 Compare November 4, 2024 19:00
@CLAassistant
Copy link

CLAassistant commented Nov 4, 2024

CLA assistant check
All committers have signed the CLA.

@sun-mota sun-mota force-pushed the sun/extended-component-writer/85 branch from 038dc93 to 0e3f0f3 Compare November 4, 2024 19:20
@sun-mota sun-mota merged commit e9f0621 into dhook/update-processDocs-arguments Nov 5, 2024
1 check passed
@sun-mota sun-mota deleted the sun/extended-component-writer/85 branch November 5, 2024 18:08
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.

auro-library: a feature to create a extended Auro component for wca(web component analyzer)
4 participants