Skip to content

feat: implement forc add and forc remove to add/remove dependencies #7143

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

JoE11-y
Copy link
Contributor

@JoE11-y JoE11-y commented May 3, 2025

Description

Close #2369

Summary:
Implements functionality for forc to add remove dependencies through cli, similar to Cargo's add and remove commands.

Work Done:

  • ✅ Added forc add command to support adding both regular and contract dependencies from path, git, IPFS, or version.
  • ✅ Implemented conflict checks for version + source collisions (e.g., version + git).
  • ✅ Added automatic fallback to workspace-relative path for local packages.
  • ✅ Introduced forc remove to cleanly remove specified dependencies from the manifest.
  • ✅ Modularized update logic using DepSection enum for unified regular/contract dependency handling.
  • ✅ Used toml_edit to update the manifest file while preserving formatting.

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@JoE11-y JoE11-y requested review from a team as code owners May 3, 2025 11:17
@JoE11-y JoE11-y temporarily deployed to fuel-sway-bot May 3, 2025 11:18 — with GitHub Actions Inactive
@JoE11-y
Copy link
Contributor Author

JoE11-y commented May 3, 2025

@IGI-111 this is ready for review.

I also noticed something, i was unable to trigger the lockfile update by just updating the members_manifest, it only worked when the forc.toml was already updated with new dependencies.

Copy link

codspeed-hq bot commented May 3, 2025

CodSpeed Performance Report

Merging #7143 will not alter performance

Comparing JoE11-y:feat/forc-edit-subcommands-impl (05c41e5) with master (07f8fc3)

Summary

✅ 24 untouched benchmarks

@zees-dev
Copy link
Contributor

zees-dev commented May 5, 2025

You may also want to integrate with the forc.pub registry - which would be a canonical endpoint to add dependencies.
^ Or an issue should be created to integrate with forc.pub registry - if this is to be done in a future PR.
Thoughts @sdankel, @kayagokalp?

@IGI-111
Copy link
Contributor

IGI-111 commented May 5, 2025

This looks nice but you need to add some tests and fix the CI errors before we can consider merging it.

@JoE11-y JoE11-y temporarily deployed to fuel-sway-bot May 5, 2025 10:42 — with GitHub Actions Inactive
@JoE11-y
Copy link
Contributor Author

JoE11-y commented May 5, 2025 via email

@JoE11-y JoE11-y requested review from a team as code owners May 5, 2025 21:22
@JoE11-y JoE11-y temporarily deployed to fuel-sway-bot May 5, 2025 21:23 — with GitHub Actions Inactive
@JoE11-y JoE11-y temporarily deployed to fuel-sway-bot May 5, 2025 22:42 — with GitHub Actions Inactive
@sdankel sdankel temporarily deployed to fuel-sway-bot May 6, 2025 20:36 — with GitHub Actions Inactive
@JoE11-y JoE11-y temporarily deployed to fuel-sway-bot May 6, 2025 21:25 — with GitHub Actions Inactive
@JoE11-y JoE11-y temporarily deployed to fuel-sway-bot May 7, 2025 09:22 — with GitHub Actions Inactive
@JoE11-y JoE11-y temporarily deployed to fuel-sway-bot May 7, 2025 09:46 — with GitHub Actions Inactive
@JoshuaBatty
Copy link
Member

JoshuaBatty commented May 9, 2025

Hey @JoE11-y thanks for the PR. Just letting you know I plan to look at this properly on Monday.

@JoE11-y JoE11-y temporarily deployed to fuel-sway-bot May 9, 2025 02:31 — with GitHub Actions Inactive
@JoE11-y
Copy link
Contributor Author

JoE11-y commented May 20, 2025

I think we can handle the forc add/remove failure by adding the required field in clap for them.

#[clap(value_enum, value_name = "DEP_SPEC", required = true)]
pub dependencies: Vec<String>

Thank you @zees-dev and @kayagokalp ❤️

@JoE11-y JoE11-y dismissed stale reviews from kayagokalp and zees-dev via 06f1535 May 21, 2025 00:32
@JoE11-y
Copy link
Contributor Author

JoE11-y commented May 21, 2025

@zees-dev @kayagokalp resolved the comment removal issue and the forc add without dep failure.

Thanks for helping reach this stage of the pr.
It's been an exciting one.

And my apologies for being a little over zealous.🫡

@JoE11-y JoE11-y temporarily deployed to fuel-sway-bot May 21, 2025 00:34 — with GitHub Actions Inactive
@JoE11-y JoE11-y requested review from kayagokalp and zees-dev May 21, 2025 01:08
kayagokalp
kayagokalp previously approved these changes May 21, 2025
zees-dev
zees-dev previously approved these changes May 22, 2025
@fuel-cla-bot
Copy link

fuel-cla-bot bot commented May 22, 2025

Thanks for the contribution! Before we can merge this, we need @sdankel to sign the Fuel Labs Contributor License Agreement.

@JoshuaBatty JoshuaBatty enabled auto-merge (squash) May 22, 2025 02:21
@kayagokalp
Copy link
Member

kayagokalp commented May 22, 2025

Hey @JoE11-y, can you squash your changes by any chance? It seems like our ci step is blocked, as we have a commit in this branch (merge master commit) from a team member that recently left and the ci cla step is blocking because of that. If you can squash your commits and force push to this branch that will go away or you can override the author of each commit to this branch to be you.

you should be able to somehting like:

git reset --soft master
git add ...
git commit -m "feat: implement forc add and forc remove to add/remove dependencies"
git push origin feat/forc-edit-subcommands-impl -f

auto-merge was automatically disabled May 22, 2025 03:37

Head branch was pushed to by a user without write access

@JoE11-y JoE11-y dismissed stale reviews from kayagokalp and zees-dev via ee99a9b May 22, 2025 03:37
@JoE11-y JoE11-y force-pushed the feat/forc-edit-subcommands-impl branch from 6fccaf0 to ee99a9b Compare May 22, 2025 03:37
@JoE11-y JoE11-y temporarily deployed to fuel-sway-bot May 22, 2025 03:40 — with GitHub Actions Inactive
@JoE11-y JoE11-y requested review from kayagokalp and zees-dev May 22, 2025 03:57
@JoE11-y JoE11-y deployed to fuel-sway-bot May 22, 2025 03:58 — with GitHub Actions Active
@JoE11-y
Copy link
Contributor Author

JoE11-y commented May 22, 2025

Hi @kayagokalp all done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a subcommand to forc to edit third party dependencies similar to Cargo
6 participants