forcedep
v1.0.1
Published
Salesforce dependency analysis CLI
Downloads
263
Readme
ForceDep
Salesforce dependency analysis CLI
ForceDep helps Salesforce developers understand what a component references and which components reference it, without manually searching through the entire codebase. It analyzes relationships between Salesforce components and provides recursive dependency trees and impact analysis.
ForceDep currently supports dependency analysis across:
- Apex Classes
- Apex Triggers
- Lightning Web Components (LWC)
- Salesforce Flows
Supported relationships include:
- Apex → Apex
- Trigger → Apex
- LWC → Apex
- Flow → Apex
- Flow → Flow
Features
- Apex dependency tracing
- Trigger → Apex dependency analysis
- LWC → Apex dependency analysis
- Flow → Apex dependency analysis
- Flow → Flow dependency analysis
- Recursive dependency trees
- Circular dependency detection
- Impact analysis
- Component filtering
- Apex category filtering
- Test-class inclusion
- Smart component name suggestions
- Performance-optimized dependency parsing
Installation
Install ForceDep globally via npm:
npm install -g forcedepVerify your installation:
fdp --versionExample output:
ForceDep v1.0.0
Salesforce dependency analysis CLI
License: GPL-3.0-or-later
Developed by: Akshay KhairnarBasic Usage
Important: Local Metadata Required
ForceDep analyzes Salesforce metadata available in your local project. You must retrieve or sync the relevant Salesforce metadata to your local machine before running a trace.
For example:
fdp trace AccountTriggerHelperFor accurate dependency results, your local project directory must contain the actual files that ForceDep needs to analyze.
ForceDep v1 analyzes local Salesforce metadata. It does not currently retrieve metadata directly from a connected Salesforce org.
To trace the immediate dependencies of a component, use the trace command:
fdp trace <component>Example:
fdp trace AccountTriggerHelperBy default, trace shows the immediate dependency context (depth of 1) of the target component rather than recursively expanding the entire dependency graph.
Terminology:
- Referenced By: Components that reference the target component.
- References: Components that the target component references.
Example output:
🌳 Apex: AccountTriggerHelper
├── Referenced By
│ ├── Trigger: AccountTrigger
│ ├── Apex: AccountTriggerHandler
│ └── Flow: Evaluate_Account_Documents
│
└── References
├── Apex: NightlySyncBatch
└── Apex: AccountServiceControllerTrace Options
| Option | Description |
| --- | --- |
| --include tests | Include Apex test classes in the trace |
| --exclude triggers | Exclude Apex triggers |
| --exclude lwc | Exclude Lightning Web Components |
| --exclude flows | Exclude Salesforce Flows |
| --only <category> | Only include Apex classes of a specific category |
| --sametype | Only trace dependencies of the same component type |
| --all | Show the full recursive dependency tree |
| --impact | Generate an impact analysis report instead of a tree |
--only Categories
The --only option filters Apex classes by their detected architecture/category. Note that this applies only to Apex classes, not Triggers, LWCs, or Flows.
Supported categories:
queueable:fdp trace AccountTriggerHelper --only queueableschedulable:fdp trace AccountTriggerHelper --only schedulableutility:fdp trace AccountTriggerHelper --only utilitywrapper:fdp trace AccountTriggerHelper --only wrappertrigger-handler:fdp trace AccountTriggerHelper --only trigger-handler
Include / Exclude Examples
Filter specific component types from your trace:
# Include test classes in the tree (excluded by default)
fdp trace AccountTriggerHelper --include tests
# Remove triggers from the trace output
fdp trace AccountTriggerHelper --exclude triggers
# Remove Lightning Web Components from the trace output
fdp trace AccountTriggerHelper --exclude lwc
# Remove Salesforce Flows from the trace output
fdp trace AccountTriggerHelper --exclude flowsCombined Commands
ForceDep supports combining options for highly specific queries:
# Exclude both Triggers and LWCs
fdp trace AccountTriggerHelper --exclude triggers --exclude lwc
# Exclude Triggers, LWCs, and Flows
fdp trace AccountTriggerHelper --exclude triggers --exclude lwc --exclude flows
# See the impact analysis without factoring in flows
fdp trace AccountTriggerHelper --exclude flows --impact
# Only see wrapper classes that match the root component's type (Apex)
fdp trace AccountTriggerHelper --sametype --only wrapper
# View wrapper classes of the same type, including test classes
fdp trace AccountTriggerHelper --sametype --only wrapper --include tests
# View the full recursive tree, but hide all UI and trigger components
fdp trace AccountTriggerHelper --all --exclude triggers --exclude lwcRecursive Trace
To view the complete, multi-level dependency tree:
fdp trace AccountTriggerHelper --allThe default trace only shows immediate neighbors. --all recursively traverses reachable dependencies and dependents. Circular dependencies are safely detected and displayed instead of causing infinite traversal.
Impact Analysis
Impact Analysis provides a compact numerical view of the reachable dependency impact instead of printing the full dependency tree.
fdp trace AccountTriggerHelper --impactExample Output:
Impact Analysis
Component
─────────
Apex: AccountTriggerHelper
Impact
──────
Affected Components : 48
Dependency Depth : 12
Circular Dependencies : 0
Component Types
───────────────
Apex Classes : 40
Triggers : 3
Flows : 1
LWCs : 4
Apex Categories
───────────────
Helpers : 6
Controllers : 6
Queueables : 5
Batches : 6(Note: These numbers are examples and will vary based on your specific Salesforce project.)
Same Type
ForceDep detects the root component's type and can restrict the trace exclusively to components of that same type.
Apex Example:
fdp trace AccountTriggerHelper --sametypeFlow Example:
fdp trace Evaluate_Account_Documents --sametypeFlow Example
Flow components can be traced just like Apex classes:
fdp trace Evaluate_Account_DocumentsTo see recursive flow dependencies:
fdp trace Evaluate_Account_Documents --allThe Flow dependency parser detects supported Apex actions and Subflow relationships directly from the XML metadata.
Global Help and Version
Global Options:
fdp --helporfdp -h: Display the main ForceDep CLI help, including available commands.fdp --versionorfdp -V: Display the current ForceDep version, license, and author.
Command-specific help:
fdp trace --help: Display the options and examples specific to thetracecommand.
Supported Components
| Component | Supported | | --- | --- | | Apex Classes | Yes | | Apex Triggers | Yes | | Lightning Web Components | Yes | | Salesforce Flows | Yes |
Performance
ForceDep performs project-wide dependency analysis and uses optimized dependency parsing along with concurrent file I/O to keep tracing responsive on larger Salesforce projects.
License
ForceDep is licensed under the GNU General Public License v3.0 or later (GPL-3.0-or-later).
Author
Developed by Akshay Khairnar.
