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

Forc.toml metadata support #6728

Merged
merged 14 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions docs/book/src/forc/manifest_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The `Forc.toml` (the _manifest_ file) is a compulsory file for each package and
* For the recommended way of selecting an entry point of large libraries please take a look at: [Libraries](./../sway-program-types/libraries.md)
* `implicit-std` - Controls whether provided `std` version (with the current `forc` version) will get added as a dependency _implicitly_. _Unless you know what you are doing, leave this as default._
* `forc-version` - The minimum forc version required for this project to work properly.
* `metadata` - Metadata for the project; can be used by tools which would like to store package configuration in `Forc.toml`.

* [`[dependencies]`](#the-dependencies-section) — Defines the dependencies.
* `[network]` — Defines a network for forc to interact with.
Expand Down Expand Up @@ -41,8 +42,64 @@ entry = "main.sw"
organization = "Fuel_Labs"
license = "Apache-2.0"
name = "wallet_contract"

[project.metadata]
indexing = { namespace = "counter-contract", schema_path = "out/release/counter-contract-abi.json" }
```

### Metadata Section in Forc.toml
zees-dev marked this conversation as resolved.
Show resolved Hide resolved

The `[project.metadata]` section provides a dedicated space for external tools and plugins to store their configuration in `Forc.toml`. The metadata key names are arbitrary and do not need to match the tool's name.

#### Usage

Use any descriptive key name for your metadata table:

```toml
[project.metadata.any_name_here]
option1 = "value"
option2 = "value"

[project.metadata.my_custom_config]
setting1 = "value"
setting2 = "value"
```

Example from an indexing tool:

```toml
[project.metadata.indexing]
namespace = "counter-contract"
schema_path = "out/release/counter-contract-abi.json"
```

#### Guidelines for Plugin Developers

Best Practices

* Choose clear, descriptive metadata key names
* Document the exact metadata key name your tool expects
* Don't require `Forc.toml` if tool can function without it
* Consider using TOML format for dedicated config files

Implementation Notes

* The metadata section is optional
* Forc does not parse metadata contents
* Plugin developers handle their own configuration parsing
zees-dev marked this conversation as resolved.
Show resolved Hide resolved
* Choose unique metadata keys to avoid conflicts with other tools

#### Example Use Cases

* Documentation generation settings
* Formatter configurations
* Debugger options
* Wallet integration
* Contract indexing
* Testing frameworks

This allows for a streamlined developer experience while maintaining clear separation between core Forc functionality and third-party tools.

## The `[dependencies]` section

The following fields can be provided with a dependency:
Expand Down
Loading
Loading