Repository navigation
feat: per-DependencyType default options under PSDependOptions - #207
Open
HeyItsGilbert wants to merge 1 commit into
Open
HeyItsGilbert wants to merge 1 commit into
HeyItsGilbert wants to merge 1 commit into
Conversation
- Adds a 3-tier option cascade: a Dependency's own value overrides a per-type default (a nested hashtable under PSDependOptions keyed by DependencyType) overrides the existing global default. - Renames the private Get-GlobalOption helper to Resolve-DependencyOption to reflect its widened responsibility. - Warns (non-fatal) when a per-type block names a DependencyType no Dependency in the file uses. - No lock-format change needed: resolution happens before a parsed Dependency reaches Resolve-PSDependLock/Merge-PSDependLock. - Adds docs/adr/0003-per-type-dependency-options.md, merges the new Global default / Per-type default terms into CONTEXT.md, updates comment-based help and about_PSDepend_Definitions.help.txt, and adds a CHANGELOG entry. - 6 new Pester tests covering the cascade, whole-value override (not a deep merge), the typo warning, and per-type Credential resolution. Fixes #42
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Explicit dependency syntax drops configured credentials, breaking authenticated repository requests, and an explicit AddToPath=false is ignored when the per-type default is true.
2 open issues
What changed in this PR
Adds per-DependencyType defaults to PSDependOptions, addressing #42 by introducing a middle tier between global defaults and dependency-specific values in the core parser.
Changes:
- Adds per-type option resolution and warnings for unused per-type blocks.
- Adds six tests covering precedence, whole-value overrides, warnings, and credential resolution.
- Documents the syntax, reserved option names, and design decisions.
| File | Description |
|---|---|
Tests/PSDepend.Tests.ps1 |
Adds six tests for per-type defaults. |
PSDepend/Public/Get-Dependency.ps1 |
Implements the resolution tier and unused-block warnings. |
PSDepend/en-US/about_PSDepend_Definitions.help.txt |
Documents per-type syntax and reserved names. |
docs/adr/0003-per-type-dependency-options.md |
Records cascade and whole-value override decisions. |
CONTEXT.md |
Defines global and per-type default terminology. |
CHANGELOG.md |
Announces the feature under Unreleased. |
Review effort: Balanced
| Tags = Resolve-DependencyOption -Name Tags -DependencyType $SplitDependencyType | ||
| DependsOn = Resolve-DependencyOption -Name DependsOn -DependencyType $SplitDependencyType | ||
| PreScripts = Resolve-DependencyOption -Name PreScripts -DependencyType $SplitDependencyType | ||
| PostScripts = Resolve-DependencyOption -Name PostScripts -DependencyType $SplitDependencyType |
| Parameters = Resolve-DependencyOption -Name Parameters -DependencyType $DependencyType -Prefer $DependencyHash.Parameters | ||
| Source = Resolve-DependencyOption -Name Source -DependencyType $DependencyType -Prefer $DependencyHash.Source | ||
| Target = Resolve-DependencyOption -Name Target -DependencyType $DependencyType -Prefer $DependencyHash.Target | ||
| AddToPath = Resolve-DependencyOption -Name AddToPath -DependencyType $DependencyType -Prefer $DependencyHash.AddToPath |
Test Results 3 files 90 suites 2m 23s ⏱️ Results for commit 4e6ad6c. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
A
PSDependOptionskey is read as a per-type block only when its value is ahashtable and its name isn't one of the 9 reserved scalar option names
(
Source,Target,Parameters,AddToPath,Tags,DependsOn,PreScripts,PostScripts,Credential) — so aDependencyTypecan neverbe named one of those.
Closes #42.
Evidence
PSDependOptionsonly supported asingle global default per option, shared across every
DependencyTypeinthe file (544 tests passing on
main).After:
./build.ps1full suite — 550 passed, 0 failed (6 new tests:cascade precedence, whole-value override vs. deep merge, the typo warning,
and per-type
Credentialresolution for the barePSGalleryModulesyntax).Merge Danger
Door: Two-way. Purely additive: a
PSDependOptionskey is only read as aper-type block when it's a hashtable keyed by an actual
DependencyTypename, so every existing
.depend.psd1/requirements.psd1file parsesidentically to before. The
Get-GlobalOption→Resolve-DependencyOptionrename is a private, unexported function (verified with a repo-wide grep)
with no external callers.
Blast Radius: Core.
Get-Dependencyis the entry point every publiccmdlet (
Invoke-PSDepend,Install-Dependency, lock resolution, etc.) goesthrough, so a resolution bug here would be widely felt — mitigated by the
cascade only activating on the new nested-hashtable syntax and the full
regression suite passing unchanged.