feat: add updateAddon.py automated tool to complement existing#41
feat: add updateAddon.py automated tool to complement existing#41abdel792 wants to merge 21 commits into
Conversation
…ration merges for legacy add-ons. - Add tomlkit to project dependencies in pyproject.toml to support robust AST-aware TOML parsing. - Update updatingExistingAddons.md to provide clear instructions and prerequisites for the new automated tool. - Exclude the update script from ruff and pyright configurations to prevent strict environment linting conflicts.
|
Hi @nvdaes, I have just added you as a collaborator to this repository. If you have some time and interest, feel free to directly review and update the docstrings in Thank you so much for your help and guidance on this! |
|
Thanks @abdel792 . I've accepted your invitation as a collaborator, and I'll try to update the docstrings. |
|
@abdel792 , can we add a way to ignore files which shouldn't be merged? |
|
Thanks a lot @nvdaes for your quick commits and for improving the docstrings and file headers! Regarding your suggestions:
I'll let you know once I've drafted the file-ignoring feature so we can test it. Thanks again for your amazing collaboration! |
|
@abdel792 , I've reorganized the documentation so that info about the script is at the start. Perhaps the information about merge should be removed= |
- Remove trailing "Press Enter to exit..." prompt at successful script completion to allow seamless execution in automated environments. - Implement specific file/folder exclusion handling during synchronization, with full architecture setup requested by @CyrilleB79.
|
Hi @nvdaes, Thank you so much for updating the documentation! It looks great and makes using the automated tool very clear. Could you please do me a favor and also integrate the new feature requested by @CyrilleB79 that I just implemented in my latest commit? It allows developers to exclude specific template files during synchronization. Here is the markdown section that needs to be added to the documentation (you can place it right before the build verification step): ### Excluding specific template files
By default, the script synchronizes every infrastructure file provided by AddonTemplate.
If you want to preserve specific files from your repository (for example, a customized GitHub workflow), you can exclude them from synchronization.
Open `updateAddon.py` and locate the `IGNORED_FILES` set near the beginning of the `main()` function:
```python
IGNORED_FILES = {
os.path.join(".github", "workflows", "build_addon.yml").lower(),
}Add any relative path from the template root to this set to prevent that file from being synchronized. |
|
Hi @nvdaes, While looking closely at our documentation, I am considering a complete overhaul and restructuring of the documentation files to make everything cleaner, more cohesive, and easier to navigate for developers. Before diving into this, I wanted to open a discussion here to get your thoughts, ideas, or any suggestions you might have regarding how we should reorganize the content. Let me know what you think! |
- Completely restructure the guide to separate the recommended automated tool method from the manual Git merge workflow. - Integrate detailed instructions for the automated companion script (`updateAddon.py`). - Document the new template synchronization exclusions feature (`IGNORED_FILES`). - Improve overall clarity, formatting, and prerequisites for initial repository setup.
|
I have just committed a complete overhaul and reorganization of the update documentation ( In this update, I have:
Please let me know if you have any feedback or further suggestions. @nvdaes, please feel free to add, modify, or correct anything you see fit—you have the green light, of course! |
There was a problem hiding this comment.
Pull request overview
This PR introduces a developer-facing automation tool (updateAddon.py) intended to help migrate/update existing NVDA add-ons to the modern AddonTemplate structure, alongside documentation and dependency updates to support that workflow.
Changes:
- Added
updateAddon.pyto clone the latest AddonTemplate, sync infrastructure files, and mergebuildVars.py/pyproject.toml. - Updated
pyproject.tomldependencies (pyright bump + new tomlkit dependency) and excludedupdateAddon.pyfrom ruff/pyright checks. - Expanded
docs/managementFromGit/updatingExistingAddons.mdwith an “automated update” path plus revised manual instructions.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 11 comments.
| File | Description |
|---|---|
| updateAddon.py | New CLI tool that syncs template infrastructure and performs AST/TOML-based merges. |
| pyproject.toml | Adds tomlkit dependency and excludes the new script from lint/type-checking; bumps pyright. |
| docs/managementFromGit/updatingExistingAddons.md | Documents the new automated update workflow and revises the manual update steps. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
I suggest renaming |
|
Hi @wmhn1872265132, Thanks for the suggestion! However, I'm concerned that renaming it to updateTemplate.py might be a bit misleading. In this context, the "template" refers specifically to the upstream nvaccess/AddonTemplate repository. We aren't actually updating the template itself; rather, we are updating the local addon repository's infrastructure to align with the latest template standards. Keeping updateAddon.py helps clarify that the target of the update is the addon's repository, not the template. |
|
Hi all! You are discussing and working a lot and I'm not able to follow all this as would be needed, sorry. It's not clear to me if this tool is needed:
@abdel792 you write:
Do you mean in case 1 or case 2? If you meant case 2, it's not true at all. I too have had merge difficulties to update my add-ons from template, e.g. when the structure of the To me, upgrades from template now work correctly and I do not ask personally a new tool to perform this work, and won't probably need to use it. Sorry for the confusion. Of course, I have a lot of commits coming from the template in my add-on's history. This may be considered undesirable by some. To me, it's not a problem. I can easily ignore them doing Also small suggestion regarding the name: what about |
|
@CyrilleB79 wrote:
Imo, it's a good addition:
|
|
Sorry @nvdaes, I do not question the usefulness of tis tool. My question is if this tool is meant to address case 1 (first update of add-on from template), or case 2 (regular updates from template). |
|
@CyrilleB79 wrote:
My understanding is that this covers both cases, but I may be wrong. Let's wait for Abdel's reply. |
|
Hi @CyrilleB79, thank you for sharing your thoughts! And thanks @nvdaes for jumping in with those excellent points. To answer your question directly: as @nvdaes suspected, this tool is designed to address both cases.
It's completely optional, of course! Your manual Git merge workflow remains fully supported and valid (and is still detailed in the documentation). This tool simply offers a streamlined alternative. Regarding the name suggestion: |
- Rename `updateAddon.py` to `updateAddonFromTemplate.py` for clarity. - Update `pyproject.toml` to exclude the renamed script from ruff and pyright. - Overhaul `updatingExistingAddons.md` documentation to match the new script name and integrate Copilot's review recommendations regarding prerequisites, correct paths, and accurate backup details.
|
Hi everyone, I have just pushed a new update to address all the valuable feedback received from Copilot and the community:
Thank you all for this amazing collaboration! I'll mark the corresponding review conversations as resolved. |
- Fix initial repository cloning paths by adding missing folder transition. - Document both standard and target directory execution modes (`addonDir`). - Align minimum Python requirements to 3.13 to match upstream template. - Clarify dynamic full-copy backup directory naming schema (`<addon>_bak_<timestamp>`). - Add comprehensive structural explanations for both legacy dictionary-based and modern AddonInfo-based add-on updates. - Note that `IGNORED_FILES` configuration supports excluding whole directories.
|
Hi everyone, I have just pushed a new commit to update the documentation (
@seanbudd: In my opinion, the PR is now in excellent shape and ready for review/merge. Please feel free to trigger a new Copilot code review cycle if you would like to verify everything. @nvdaes, @CyrilleB79, and everyone else: please let me know if you have any additional feedback or final suggestions before we move forward! |
…ExistingAddons.md - Fix broken Markdown syntax for the backup directory naming template. - Remove redundant folder transition step from the initial setup guide. - Refine typography and adopt a neutral technical tone by removing promotional phrasing. - Apply overall documentation adjustments to improve layout and workflow clarity.
Yes this fully makes sense, thanks for these additional explanations. Seems that I have forgotten a bit the times when I was myself a beginner with Git and when Noelia or you were kindly answering my newbe questions! I'll try to review your work, but not sure to be able to. So do not wait for me to go forward, i.e. for merging. |
|
@CyrilleB79 , I'd like to thank you, even when I'm not Abdel, for all your reviews making good questions to think about. |
|
Hi @CyrilleB79, Thank you so much! Your feedback is always incredibly valuable, and the questions you raise are exactly what helps ensure the solutions we build together are robust and cover all bases. Never apologize for asking or double-checking—it's precisely these kinds of reviews that prevent oversights and improve the workflow for everyone. Please feel free to continue using your current manual Git merge workflow without any problem! The automated script is completely optional and just intended as an alternative helper. Both approaches (the manual workflow and the automated script) are now fully and clearly detailed in the updated documentation, so every developer can choose the method they feel most comfortable with. No worries at all regarding the review, please take all the time you need, and don't worry if you cannot look into it right now. Thanks again for your amazing support and kindness! |
…ted pyproject.toml Updated `mergePyprojectToml` to configure `tomlkit` with `.multiline(True)` when programmatically migrating legacy `addon_author` metadata. This ensures that authors/maintainers are generated in a clean, vertically indented structure during initial add-on template migrations, matching official repository design guidelines.
|
Hi everyone, I have just pushed a final update to the PR to address the @nvdaes, could you please perform the verification steps that I am going to outline in my next comment? This will help us confirm the review and validate the script's behavior together for @seanbudd. If everything works smoothly on your end, we will be ready to ask @seanbudd for an official merge. Thank you so much! |
Testing and Review Guide for
|
|
@abdel792 , I've following your instructions and my results are the following:
|
|
Hi @nvdaes, You are entirely right! Since To explain exactly why this happened during your tests:
The best solution is indeed to include To make it as easy as possible and let you run the script globally from anywhere right now, you can simply install (or update) py -m pip install -U tomlkit(Note: If someone's system uses Could you please try running the tests again after installing Once that is done, your global Python environment will have the required module, and you can comfortably run the two test cases exactly as described in the guide using your standard Thank you so much for pointing this out—I'll update the prerequisites in our documentation right away! |
|
@abdel792, I've tested the legacy add-on now:
|
|
Tested modern add-on:
|
|
Finally, for advanced testing, after seen the script, I've changed the way of performing tests. I've seen that buildAddon.yml is added as an ignored file. Since this wasn't included in the legacy add-on, I've removed it from the dictionary of IGNORED_FILES, and I've run the script again. Hope this helps. |
Update the prerequisites section in updatingExistingAddons.md to document that `tomlkit` must be installed globally before running `updateAddonFromTemplate.py`. This ensures users don't encounter missing module errors when executing the script on legacy repositories or before the upstream template merges the new dependency.
|
Hi @nvdaes, Wow, thank you so much for this extremely thorough test run! This is incredibly helpful. Here are a few quick insights based on your amazing feedback:
Following your discovery about the missing package error, I have also just updated the prerequisites section in the documentation ( Overall, this confirms that the legacy dictionary migration, the modern key injection ( Thank you so much, Noelia! I think we are in a perfect position to move forward. |
|
Thank you very much, Abdel! |
Commented out the default `build_addon.yml` path entry within the `IGNORED_FILES` set in `updateAddonFromTemplate.py`. This ensures all infrastructure components are synchronized out of the box while providing developers with a clear syntax example for excluding custom files or directories.
|
Hi everyone, I have just pushed an update to comment out the This ensures that all infrastructure files are synchronized out of the box by default, while still providing developers with a clear, practical example of the exact path syntax to use if they want to exclude their own files or directories. Thanks! |
|
Hi @nvdaes, You are completely right! Using Also, just a quick heads-up: following your successful advanced test, I have just pushed an update to comment out the Thanks again for your amazing review and collaboration on this. I think we are all set! |
|
Hi @seanbudd, Everything is now ready for review and merge! We have just completed a thorough final round of testing and revisions with @nvdaes, and the automation tool is working beautifully exactly as designed. Based on the community feedback, I have also updated the prerequisites documentation to ensure a seamless setup experience for all developers. If you have no further comments or questions, this PR is ready to go—unless you would prefer to trigger a final Copilot code review cycle first. Thank you so much for your guidance and support throughout this process! |
Updated the `mergePyprojectToml` function in `updateAddonFromTemplate.py` to ensure that when a new `pyproject.toml` is created from the template for legacy add-ons, any generated multiline arrays (such as `maintainers`) strictly use tab indentation instead of four spaces.
|
Hi @nvdaes, I have just pushed a quick fix to resolve the indentation issue you noticed during the legacy add-on migration! When creating the new Could you please run the legacy add-on test case one more time whenever you have a moment, just to verify that the indentation is now perfectly rendered as tabs on your end? Thank you so much for your help! |
|
@abdel792 , I've tested the legacy add-on as requested, and now maintainers are indented perfectly, with two spaces! |
|
Hi @nvdaes, Thank you so much for the super quick re-test and confirmation! I'm glad to see the indentation issue is now fully sorted out for the legacy migration path. Before we move forward, do you have any other revisions, suggestions, or comments you'd like to add? For instance, regarding the documentation or anything else? From my side, all testing rounds are completely successful and conclusive. The automation tool is now perfectly capable of updating an add-on repository running any version of the addonTemplate without any issues. Hi @seanbudd, As everything is now fully tested and working beautifully, @nvdaes and I are completely aligned and ready to move forward. If you have any final suggestions, comments, or would like to trigger a last Copilot code review cycle first, please let us know. Otherwise, this PR is officially ready to be merged! Thanks everyone for the fantastic support and collaboration! |
Link to issue number:
Close #37.
Summary of the issue:
Upgrading an existing add-on to follow the modern
addonTemplatestructure manually is a repetitive and error-prone process. Developers frequently encounter syntax issues or merge conflicts when manually porting old metadata into the newpyproject.tomlstructure.Description of developer facing changes:
Introduces an automated update workflow. Developers can now run a single command (
uv run updateAddon.py) from any directory on their PC to automatically migrate metadata, clean template placeholder data (like removingnvaccessfrom third-party authors lists), and merge project configurations while preserving custom formatting.Description of development approach
updateAddon.pyat the repository root. The script leverages an AST-aware (Abstract Syntax Tree) approach to perform safe, robust parsing and merging of TOML structures.tomlkit==0.13.0under the# Update machinerysection inpyproject.tomlto support programmatic, comment-preserving TOML modifications.updateAddon.pyto theexcludelists of both[tool.ruff]and[tool.pyright]withinpyproject.tomlto avoid unnecessary environmental or strict typing alerts during standard repository validation.updatingExistingAddons.mdto cleanly integrate prerequisites (Python 3.11+, Git available in PATH) and step-by-step instructions on how to use this new companion tool alongside the existing manual instructions.Testing strategy:
The script and documentation workflow have been tested locally:
git fetch templateto ensure local tracking branches were up to date.uv run updateAddon.pyfrom the repository root, and verified that a_bak_backup directory was safely generated.pyproject.tomlto ensure old custom metadata was correctly merged, template placeholder defaults were stripped, and file formatting/comments remained completely intact.uv syncfollowed byuv run sconsto ensure the final environment synchronized properly and the.nvda-addonbundle compiled successfully with zero errors.Known issues with pull request:
None.
Code Review Checklist
updatingExistingAddons.md) has been explicitly updated to reflect these changes.