|
| 1 | +# PSDepend |
| 2 | + |
| 3 | +A PowerShell dependency handler that resolves, installs, imports, and tests dependencies declared in `.psd1` files using a pluggable set of DependencyScripts. |
| 4 | + |
| 5 | +## Language |
| 6 | + |
| 7 | +**Dependency**: |
| 8 | +The unit of work — a named, versioned item to be resolved, with a DependencyType, Target, Tags, and optional Prerequisites. |
| 9 | +_Avoid_: package, module, requirement |
| 10 | + |
| 11 | +**DependencyFile**: |
| 12 | +A `.psd1` file that declares one or more Dependencies. Filename is arbitrary; `requirements.psd1` is conventional, not canonical. |
| 13 | +_Avoid_: requirements file, depend file, manifest |
| 14 | + |
| 15 | +**DependencyType**: |
| 16 | +The registered identifier that selects which DependencyScript handles a Dependency (e.g., `PSGalleryModule`, `Git`, `Chocolatey`). |
| 17 | +_Avoid_: type, provider, handler type |
| 18 | + |
| 19 | +**DependencyScript**: |
| 20 | +A `PSDependScripts/<Type>.ps1` file that implements a DependencyType. Receives a typed Dependency object and a set of PSDependAction flags. |
| 21 | +_Avoid_: handler, plugin, provider |
| 22 | + |
| 23 | +**PSDependAction**: |
| 24 | +A set of flags (`Install`, `Test`, `Import`) passed to a DependencyScript. Flags are combinable; DependencyScripts must handle each valid combination. |
| 25 | +_Avoid_: mode, command, operation |
| 26 | + |
| 27 | +**Target**: |
| 28 | +A Dependency field with dual semantics: a scope keyword (`AllUsers`, `CurrentUser`) or a filesystem path. DependencyScripts branch explicitly on which it is. |
| 29 | +_Avoid_: destination, scope, path (use Target regardless of which semantic applies) |
| 30 | + |
| 31 | +**PSDependOptions**: |
| 32 | +A reserved key in a DependencyFile that sets default field values applied to all Dependencies in that file. |
| 33 | +_Avoid_: defaults, global options, file options |
| 34 | + |
| 35 | +**Prerequisite**: |
| 36 | +A declared ordering constraint between Dependencies. Expressed via the `DependsOn` field; resolved into topological execution order before dispatch. |
| 37 | +_Avoid_: dependency (to avoid confusion with the Dependency concept), requirement |
| 38 | + |
| 39 | +**Tag**: |
| 40 | +A label on a Dependency that controls inclusion when `Invoke-PSDepend` is called with `-Tags`. |
| 41 | +_Avoid_: filter, category, label |
| 42 | + |
| 43 | +## Relationships |
| 44 | + |
| 45 | +- A **DependencyFile** contains one or more **Dependencies** and at most one **PSDependOptions** block |
| 46 | +- A **Dependency** has exactly one **DependencyType**, which selects exactly one **DependencyScript** |
| 47 | +- A **Dependency** may declare zero or more **Prerequisites** (other Dependencies that must resolve first) |
| 48 | +- A **Dependency** may carry zero or more **Tags** |
| 49 | +- A **DependencyScript** receives a **Dependency** and a set of **PSDependAction** flags on each invocation |
| 50 | +- **Target** is a field on a **Dependency** interpreted differently by each **DependencyScript** |
| 51 | + |
| 52 | +## Example dialogue |
| 53 | + |
| 54 | +> **Dev:** "Should I add the new module as a dependency or a requirement?" |
| 55 | +> **Domain expert:** "It's a **Dependency** — declared in a **DependencyFile** with `DependencyType = 'PSGalleryModule'`." |
| 56 | +
|
| 57 | +> **Dev:** "Where does it get installed — do I set the path or the scope?" |
| 58 | +> **Domain expert:** "Both are **Target**. If you want `CurrentUser`, set `Target = 'CurrentUser'`. If you want a specific folder, set `Target = 'C:\MyModules'`. The **DependencyScript** branches on which one it sees." |
| 59 | +
|
| 60 | +> **Dev:** "I need psake to install before PowerShellBuild. How do I express that?" |
| 61 | +> **Domain expert:** "Declare a **Prerequisite** on PowerShellBuild: `DependsOn = 'psake'`. The engine resolves all **Prerequisites** into topological order before dispatching any **DependencyScript**." |
| 62 | +
|
| 63 | +## Flagged ambiguities |
| 64 | + |
| 65 | +- "dependency" collides with **Prerequisite** in natural speech ("psake is a dependency of PowerShellBuild") — resolved: use **Prerequisite** for the ordering relationship, **Dependency** only for a declared entry in a DependencyFile. |
| 66 | +- "handler" was used in early CLAUDE.md — resolved: canonical term is **DependencyScript**. |
0 commit comments