Skip to content

frontend: remove unused ArduPilot parameter files from build#3760

Merged
patrickelectric merged 1 commit intobluerobotics:masterfrom
Williangalvani:cleanup_parameters
Feb 4, 2026
Merged

frontend: remove unused ArduPilot parameter files from build#3760
patrickelectric merged 1 commit intobluerobotics:masterfrom
Williangalvani:cleanup_parameters

Conversation

@Williangalvani
Copy link
Member

@Williangalvani Williangalvani commented Feb 4, 2026

Only keep JSON files from the ArduPilot-Parameter-Repository, removing XML, RST, MD, and HTML documentation files that are not used by the frontend.

Summary by Sourcery

Limit frontend build artifacts from the ArduPilot parameter repository to JSON-only assets to reduce bundle size.

Build:

  • Add a Vite build hook that removes non-JSON ArduPilot parameter files from the built assets directory.
  • Stop including ArduPilot-Parameter-Repository JSON files via the generic assetsInclude configuration, relying instead on the new cleanup step.

Only keep JSON files from the ArduPilot-Parameter-Repository, removing
XML, RST, MD, and HTML documentation files that are not used by the
frontend.
@sourcery-ai
Copy link

sourcery-ai bot commented Feb 4, 2026

Reviewer's Guide

Adds a Vite build plugin to remove non-JSON ArduPilot parameter repository files from the frontend build output and simplifies asset inclusion patterns to rely on the cleaned output.

Sequence diagram for Vite build cleanup of ArduPilot parameter files

sequenceDiagram
  participant ViteBuild
  participant CleanupArdupilotPlugin
  participant FileSystem

  ViteBuild->>CleanupArdupilotPlugin: closeBundle()
  CleanupArdupilotPlugin->>FileSystem: existsSync(dist/assets/ArduPilot-Parameter-Repository)
  alt repoPath exists
    CleanupArdupilotPlugin->>CleanupArdupilotPlugin: removeNonJson(repoPath)
    loop traverse_directory_tree
      CleanupArdupilotPlugin->>FileSystem: readdirSync(dir, withFileTypes)
      alt entry isDirectory
        CleanupArdupilotPlugin->>CleanupArdupilotPlugin: removeNonJson(subdirectory)
      else entry isFile
        alt name endsWith .json or .json.gz
          CleanupArdupilotPlugin-->>FileSystem: keep file
        else
          CleanupArdupilotPlugin->>FileSystem: unlinkSync(file)
        end
      end
    end
  else repoPath missing
    CleanupArdupilotPlugin-->>ViteBuild: return without changes
  end
  CleanupArdupilotPlugin-->>ViteBuild: closeBundle complete
  ViteBuild->>ViteBuild: produce final frontend assets
Loading

File-Level Changes

Change Details Files
Introduce a Vite build plugin that deletes non-JSON ArduPilot parameter repository files from the build output to reduce bundle size.
  • Add a new Vite plugin named 'cleanup-ardupilot-files' that runs on build closeBundle.
  • Implement recursive directory traversal under the built ArduPilot-Parameter-Repository assets path.
  • Delete all files that do not end with .json or .json.gz, leaving only parameter JSON data files.
  • Guard plugin execution when the repository path does not exist.
core/frontend/vite.config.js
Adjust asset inclusion configuration now that ArduPilot parameter JSON files are handled by the cleanup plugin.
  • Remove the explicit ArduPilot-Parameter-Repository JSON glob from the assetsInclude list.
  • Keep existing image, model, SVG, message, and Draco library asset patterns unchanged.
core/frontend/vite.config.js

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

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 - I've left some high level feedback:

  • In the cleanup-ardupilot-files plugin, the synchronous fs operations inside closeBundle (readdirSync/unlinkSync) run without any error handling, so a single IO error could fail the entire build; consider wrapping the traversal in try/catch and logging a warning instead of throwing.
  • By removing the ArduPilot JSON pattern from assetsInclude, JSON files that are no longer explicitly imported might not be available in dev/preview; double-check whether this pattern is still required for your dev server behavior and, if so, constrain it more narrowly instead of removing it entirely.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In the cleanup-ardupilot-files plugin, the synchronous fs operations inside closeBundle (readdirSync/unlinkSync) run without any error handling, so a single IO error could fail the entire build; consider wrapping the traversal in try/catch and logging a warning instead of throwing.
- By removing the ArduPilot JSON pattern from assetsInclude, JSON files that are no longer explicitly imported might not be available in dev/preview; double-check whether this pattern is still required for your dev server behavior and, if so, constrain it more narrowly instead of removing it entirely.

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
Member

@patrickelectric patrickelectric left a comment

Choose a reason for hiding this comment

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

I tested the PR but the dist folder is still full of files:

eae8241f ±  ls dist/assets/ArduPilot-Parameter-Repository/Plane-4.1        
apm.pdef.json  apm.pdef.xml  MAVLinkMessages.rst  ParameterMetaData.xml  Parameters.html  Parameters.md  Parameters.rst

@Williangalvani
Copy link
Member Author

I tested the PR but the dist folder is still full of files:

eae8241f ±  ls dist/assets/ArduPilot-Parameter-Repository/Plane-4.1        
apm.pdef.json  apm.pdef.xml  MAVLinkMessages.rst  ParameterMetaData.xml  Parameters.html  Parameters.md  Parameters.rst

that is odd, I don't see the files in the built image:
Screenshot 2026-02-04 at 14 19 46

@patrickelectric
Copy link
Member

just tested, the final assets folder does not contain such files, the dist folder should not be used to check them

@patrickelectric patrickelectric merged commit 66d3e39 into bluerobotics:master Feb 4, 2026
7 checks passed
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.

2 participants

Comments