Skip to content

[hooks] Add baseUri to user defines - #3522

Open
simolus3 wants to merge 6 commits into
dart-lang:mainfrom
simolus3:resolve-paths
Open

[hooks] Add baseUri to user defines#3522
simolus3 wants to merge 6 commits into
dart-lang:mainfrom
simolus3:resolve-paths

Conversation

@simolus3

@simolus3 simolus3 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Description

This adds baseUriForDefine to HookInputUserDefines`, which returns a base URI that can be used to interpret arbitrary configuration values as paths.

Additionally, it accepts a list of keys, which allows traversing through nested options (yaml maps and sequences). Path elements are either strings (used to lookup values in maps) or integers (for lookups in sequences).

This is a generalization of HookInputUserDefines.path, which allows interpreting a top-level user-define as a path. baseUriForDefine also works for nested paths and can be used to transform lists, maps or any other structure a hook might read as user-defines.

Related Issues

Fixes #3515

PR Checklist

  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
  • I've run dart tool/ci.dart --all locally and resolved all issues identified. (Too lazy, I just ran the formatter and checked for analysis errors)
  • All existing and new tests are passing. I added new tests to check the change I am making.
  • The PR is actually solving the issue. PRs that don't solve the issue will be closed. Please be respectful of the maintainers' time. If it's not clear what the issue is, feel free to ask questions on the GitHub issue before submitting a PR.
  • I have updated CHANGELOG.md for the relevant packages. (Not needed for small changes such as doc typos).
  • I have updated the pubspec package version if necessary.

@simolus3
simolus3 marked this pull request as ready for review August 5, 2026 13:57
);
}

final pathOption =

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Lol, now accessing baseUri is easier than the user-defines themselves 😄

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I can add a helper that traverses through options and returns the original define, but I suspect most hooks with complex options would use helper packages like json_serializable for this anyway.

Comment thread pkgs/hooks/lib/src/config.dart Outdated
@dcharkes
dcharkes requested a review from goderbauer August 5, 2026 14:05
@dcharkes

dcharkes commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

@goderbauer See related bug. Any preferences for an API?

@simolus3 simolus3 changed the title Add baseUriForDefine to user defines [hooks] Add baseUriForDefine to user defines Aug 5, 2026
@simolus3 simolus3 changed the title [hooks] Add baseUriForDefine to user defines [hooks] Add baseUri to user defines Aug 5, 2026

@simolus3 simolus3 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The changelog check fails because it expects a hooks_runner entry due to the test_data/ change, could I get a skip-changelog-check label for this?

Comment thread pkgs/hooks/lib/src/config.dart Outdated
Comment thread pkgs/hooks/lib/src/config.dart
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.

Allow hooks to resolve paths relative to the workspace root?

3 participants