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

Fix some small pathing issues with new script #88

Merged
merged 5 commits into from
Nov 7, 2024

Conversation

DukeFerdinand
Copy link
Contributor

@DukeFerdinand DukeFerdinand commented Nov 5, 2024

Alaska Airlines Pull Request

Since we're on a breaking change 3.0.0, there are other non-issues that will completely break your docs build, but these three commits were actually problems in the library :)

Closes #89

Before Submitting this pull request:

  • Link all tickets in this repository related to this PR in the Development section
    note: all pull requests require at least one linked ticket
  • If this PR is Ready For Review, all ticket's linked under Development must have their status changed to Ready For Review as well

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

Fix path handling issues in the fromAuroComponentRoot function and enhance file processing capabilities by adding preProcessors. Update AuroLibraryUtils to use import.meta.url for directory path determination.

Bug Fixes:

  • Fix path handling in fromAuroComponentRoot function to correctly process paths starting with a slash.

Enhancements:

  • Add preProcessors property to the FileProcessorConfig to allow additional processing on content before template filling.
  • Modify getDirname method in AuroLibraryUtils to use import.meta.url for determining the directory path.

Summary by Sourcery

Fix path handling issues in the fromAuroComponentRoot function and enhance file processing capabilities by adding preProcessors. Update AuroLibraryUtils to use import.meta.url for directory path determination.

Bug Fixes:

  • Fix path handling in fromAuroComponentRoot function to correctly process paths starting with a slash.

Enhancements:

  • Add preProcessors property to the FileProcessorConfig to allow additional processing on content before template filling.
  • Modify getDirname method in AuroLibraryUtils to use import.meta.url for determining the directory path.

- add preProcessors since api table formatting completely breaks api.md when run after templateReplacer
@DukeFerdinand DukeFerdinand self-assigned this Nov 5, 2024
@DukeFerdinand DukeFerdinand requested a review from a team as a code owner November 5, 2024 23:11
Copy link

sourcery-ai bot commented Nov 5, 2024

Reviewer's Guide by Sourcery

This PR addresses path handling issues and enhances file processing capabilities in the build scripts. The changes primarily focus on improving path resolution for component roots, adding pre-processing support for file content, and updating the directory path determination method to use ES modules' import.meta.url instead of __dirname.

Class diagram for updated AuroLibraryUtils and FileProcessorConfig

classDiagram
    class AuroLibraryUtils {
        +getDirname() string
        +getProjectRootPath string
    }
    note for AuroLibraryUtils "Updated getDirname to use import.meta.url"

    class FileProcessorConfig {
        +string|InputFileType input
        +string output
        +Partial<MarkdownMagicOptions> mdMagicConfig
        +Array<(contents: string) => string> preProcessors
        +Array<(contents: string) => string> postProcessors
    }
    note for FileProcessorConfig "Added preProcessors property"
Loading

File-Level Changes

Change Details Files
Improved path handling in the fromAuroComponentRoot function
  • Added handling for paths that start with a forward slash
  • Removed unnecessary path joining with current directory
  • Simplified path resolution logic
scripts/utils/sharedFileProcessorUtils.mjs
Enhanced file processing pipeline with pre-processor support
  • Added new preProcessors property to FileProcessorConfig
  • Implemented pre-processor execution step before template filling
  • Moved API table formatting from post-processing to pre-processing
scripts/utils/sharedFileProcessorUtils.mjs
scripts/build/processors/defaultDocsProcessor.mjs
Updated directory path determination to use ES modules approach
  • Replaced __dirname usage with import.meta.url
  • Removed conditional logic for __dirname undefined check
  • Simplified getDirname method implementation
scripts/utils/auroLibraryUtils.mjs

Assessment against linked issues

Issue Objective Addressed Explanation
#89 Fix __dirname being undefined causing path resolution to break
#89 Fix readme variant being ignored
#89 Fix api table formatting breaking the api.md file

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 @DukeFerdinand - I've reviewed your changes - here's some feedback:

Overall Comments:

  • The move of formatApiTable from postProcessors to preProcessors represents a significant change in processing order. Please document this change and its implications in the PR description.
Here's what I looked at during the review
  • 🟡 General issues: 3 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/utils/sharedFileProcessorUtils.mjs Outdated Show resolved Hide resolved
scripts/utils/sharedFileProcessorUtils.mjs Outdated Show resolved Hide resolved
scripts/utils/auroLibraryUtils.mjs Outdated Show resolved Hide resolved
Apparently it's more "correct" to do it this way :)
@DukeFerdinand
Copy link
Contributor Author

@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 @DukeFerdinand - I've reviewed your changes and found some issues that need to be addressed.

Blocking issues:

  • Bug: preProcessors loop is using postProcessors array (link)

Overall Comments:

  • There's a bug in the preProcessors implementation - it's using postProcessors array instead of preProcessors in the loop in processContentForFile
  • The default parameter was removed from fileConfigs but it's still referenced in the code. Consider keeping the default or updating all callers
Here's what I looked at during the review
  • 🔴 General issues: 1 blocking issue
  • 🟢 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/utils/sharedFileProcessorUtils.mjs Outdated Show resolved Hide resolved
- fixes preprocessor loop using wrong array
- use path.join instead of path string concat
@DukeFerdinand DukeFerdinand force-pushed the dhook/fix-small-pathing branch from a562a6f to ef7ef6f Compare November 6, 2024 17:52
@DukeFerdinand
Copy link
Contributor Author

@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 @DukeFerdinand - I've reviewed your changes - here's some feedback:

Overall Comments:

  • The removal of the default parameter in fileConfigs() could be a breaking change if code was relying on those defaults. Consider either keeping the default or documenting this change in the breaking changes section.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 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.

Copy link
Contributor

@sun-mota sun-mota left a comment

Choose a reason for hiding this comment

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

I'm getting some error prints.
npm run build:docs on Auro-flight
image

@DukeFerdinand
Copy link
Contributor Author

I'm getting some error prints. npm run build:docs on Auro-flight image

This is expected :) it's the main "breaking change" when adopting this new build script

Copy link
Contributor

@sun-mota sun-mota left a comment

Choose a reason for hiding this comment

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

confirmed this works with a change(AlaskaAirlines/auro-flight#140)

@DukeFerdinand DukeFerdinand merged commit de11fe8 into main Nov 7, 2024
4 checks passed
@DukeFerdinand DukeFerdinand deleted the dhook/fix-small-pathing branch November 7, 2024 17:36
@DukeFerdinand DukeFerdinand restored the dhook/fix-small-pathing branch November 7, 2024 17:37
@blackfalcon
Copy link
Member

🎉 This PR is included in version 3.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@blackfalcon blackfalcon added the released Completed work has been released label Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released Completed work has been released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New build script break on running in a real component
3 participants