• Stars
    star
    101
  • Rank 338,166 (Top 7 %)
  • Language
    CSS
  • License
    BSD 3-Clause "New...
  • Created about 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

SFDX plugin for metadata dependencies tooling API

dependencies-cli

Sample command line utilities around the Salesforce Dependencies API implemented as SFDX plugin.

The plugin is NOT a Salesforce supported project and release as a community project under open source licenses. Anyone is invited to help improve and extend the code.

This project implements an SFDX plugin for the Salesforce Dependencies API. With the plugin you are able to analyze dependencies between Salesforce second-generation packages as well as dependencies between Salesforce objects deployed in your org. The plugin is meant for Salesforce developers and administrators trying to

  1. Analyze package and object level dependencies
  2. Untangle large monolithic orgs to split into smaller (more managable) orgs
  3. Indentify and extract base packages with shared objects
  4. Identify package level version dependencies

The plugin does not automate any of these steps but uses graph technology to help navigate the complexities of a Salesforce org. The main output thus far is a set of D3.js force directed graphs used to visualize dependencies and recommendation actions.

Note: Some commands directly need the Salesforce Dependencies API which is currently in open beta for production orgs but fully enabled for sandbox orgs. Please make sure your org has the API enabled or work with Salesforce support to enable it.

Note: The Salesforce Dependencies API in its current form is limitted to return the first 2000 records of a full query only. As a consequence the plugin can only get the first 2000 objects and the dependency graph is incomplete. While we are wainting for the dependenies API to support full resultset pagination, treat this project as a starter project to a more complete solution.

Install

  1. Install the Salesforce CLI (SFDX)
npm install sfdx-cli --global
  1. Make sure you have the latest version
npm update sfdx-cli --global
  1. Install the plugin via npm
npm install dependencies-cli --global 
  1. Test the plugin
sfdx dependency

returns

Sample command line utilities around the Salesforce Dependencies API implemented as SFDX plugin.

USAGE
  $ sfdx dependency:COMMAND

COMMANDS


TOPICS
  Run help for each topic below to view subcommands

  dependency:component  Analyzes object level dependencies in your org
  dependency:package    Analyzes package level dependencies in your dev project
  1. Authorize an org

For production orgs use

sfdx force:auth:web:login

For sandbox orgs use

sfdx force:auth:web:login -r https://test.salesforce.com

returns

Successfully authorized <userId> with org ID <orgId>
You may now close the browser

Usage

The plugin implements two topics with a couple of commmands each:

dependency
  |-component
     |---componentizer
     |---report
  |-package
     |---merge
     |---version

The two topics help with two disjoint sets of questions where:

dependency:component Analyzes object level dependencies in your org

dependency:package Analyzes package level dependencies in your dev project

Following are a details for every command to illustrate usage only. For detailed command descriptions use

sfdx dependency:COMMAND --help

dependency:component

Analyzes object level dependencies in your org. All commands are based on the Salesforce Dependencies API and require an org connection with the -u, --targetusername=targetusername option.

dependency:component:componentizer

Return all leaf nodes in the directed component dependency graph.

USAGE:

sfdx dependency:component:componentizer [-u <string>] [--apiversion <string>] [--json]

The response lists the leaf nodes in the directed component dependency graph in a text form, grouped by object type. For example:

CustomField:
	CustomerPriority(00N2E000008r3MxUAI)
	NumberofLocations(00N2E000008r3MyUAI)
	SLA(00N2E000008r3MzUAI)
	SLAExpirationDate(00N2E000008r3N0UAI)

WebLink:
	View Campaign Influence Report(00b2E000001Yj9ZQAS)
	Billing(00b2E000001Yj9bQAC)
	Up-sell / Cross-sell Opportunity(00b2E000001Yj9cQAC)

dependency:component:report

Produces a dependency graph representing all object level dependencies in your org.

USAGE:

sfdx dependency:component:report [-r <string>] [-e <string>] [-d <string>] [-x <string> -m] [-a -i <string>] [-t undefined] [-v] [-u <string>] [--apiversion <string>] [--json]

This command produces a DOT formatted output by default if no --json option is used. Following is an example output.

digraph graphname {
  rankdir=RL;
  node[shape=Mrecord, bgcolor=black, fillcolor=lightblue, style=filled];
  // Nodes
  X00h11000000s7oIAAQ [label=<Case (Support) Layout<BR/><FONT POINT-SIZE="8">Layout</FONT>>]
  X00b11000000S28TAAS [label=<Up-sell / Cross-sell Opportunity<BR/><FONT POINT-SIZE="8">WebLink</FONT>>]
  X00h11000000s7oJAAQ [label=<Case Layout<BR/><FONT POINT-SIZE="8">Layout</FONT>>]
  X00h11000000s7oNAAQ [label=<Account (Marketing) Layout<BR/><FONT POINT-SIZE="8">Layout</FONT>>]
  X00b11000000S28SAAS [label=<Billing<BR/><FONT POINT-SIZE="8">WebLink</FONT>>]
  X00N11000002qGqQEAU [label=<Account.Contract<BR/><FONT POINT-SIZE="8">CustomField</FONT>>]
  // Paths
  X00h11000000s7oIAAQ->X00b11000000S28TAAS
  X00h11000000s7oJAAQ->X00b11000000S28TAAS
  X00h11000000s7oNAAQ->X00b11000000S28SAAS
  X00h11000000s7oNAAQ->X00N11000002qGqQEAU
}

DOT formatted output can easily be converted into a vector graph (SVG). You can either paste the output directly into this website for online rendering, or install software to build static or interactive SVG (using d3.js).

1. Render the SVG as dependency graph in an image

brew install graphviz
  • produce the DOT graph file output
sfdx dependency:component:report -u [alias|username] -r dot  | tee graph.dot

  • convert the DOT file to SVG
dot -T svg graph.dot > graph.svg
  • open the SVG directly in your browser (Google Chrome works best)
open -a "Google Chrome" graph.svg

Following is a small example of a static SVG produced with this process.

Graph

2. Render the SVG as d3-force graph

There are two options to launch the D3 graph, using either a pre-deployed Heroku app or running the app locally.

2.1 Use the Node.js app deployed at https://sfdc-mdapi-graph.herokuapp.com

  • produce the graph in JSON format
sfdx dependency:component:report -u [alias|username] --json  | tee graph.json
open -a "Google Chrome" https://sfdc-mdapi-graph.herokuapp.com

2.2 Run the Node.js app locally

  • start the local Node.js server
npm start &
  • produce the graph in JSON format
sfdx dependency:component:report -u [alias|username] --json  | tee graph.json
open -a "Google Chrome" http://localhost:8080
  • to kill the local Node.js server use
npm stop

Here an example of an interactive force directed D3 graph rendered with the above process.

D3.gif

The force directed graph supports actions to navigate a large graph better, including:

  • filter and selection by node type
  • filter and selection by node name
  • show/hide labels
  • freeze the graph simulation
  • recenter the graph
  • expand the graph for readibility
  • collapse the graph to identify center of gravity
  • remove individual nodes
  • remove a connected graph for a given node
  • expand the fully connected graph for a given node
  • export filtered subgraph

Using D3.js technology is an attempt to manage large graphs more easily. In addition, one can pass flags to the SFDX plugin directly to apply query filters based on type and thus reduce the output.

dependency:package

Analyzes package level dependencies in your development projects. All commands expect a 2nd generation Salesforce project with one or multiple package.xml.

dependency:package:merge

Merge multiple package.xmls to create one base package.xml containing only those objects available across all packages. This function computes the intersection of multiple first generation packages.

USAGE:

sfdx dependency:package:merge [-h <help>] [-d <string>] [--json]

This command produces a properly formatted package.xml as the result of the merge operation, for example:

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
	<types>
		<members>Reservation_Manager__c</members>
		<members>Spaces_Designer__c</members>
		<name>CustomTab</name>
	</types>
	<types>
		<members>Reservation_Manager</members>
		<members>Spaces_Designer</members>
		<members>Market_Record_Page</members>
		<name>FlexiPage</name>
	</types>
	<types>
		<members>Market__c</members>
		<members>Reservation__c</members>
		<name>CustomObject</name>
	</types>
	<types>
		<members>Lead Layout</members>
		<members>Campaign Layout</members>
		<name>Layout</name>
	</types>
	<version>43.0</version>
</Package>

dependency:package:version

Analyze version dependencies for packages deployed in your org using the 2nd generation development process. The command is required to run from within the SFDX project development folder and needs an org connection with the -u, --targetusername=targetusername option.

USAGE:

sfdx dependency:package:version [-v <string>] [-u <string>] [--apiversion <string>]

This command produces a DOT formatted output:

digraph graphname {
  rankdir=RL;
  node[shape=Mrecord, bgcolor=black, fillcolor=lightblue, style=filled];
  // Nodes
  X04tB0000000KAekIAG [label=<ESBaseCodeLWC 1.0.0.2<BR/><FONT POINT-SIZE="8">033B0000000buUeIAI</FONT><BR/><FONT POINT-SIZE="8">04tB0000000KAekIAG</FONT>>]
  X04tB0000000KAefIAG [label=<ESObjects 1.0.0.2<BR/><FONT POINT-SIZE="8">033B0000000buUoIAI</FONT><BR/><FONT POINT-SIZE="8">04tB0000000KAefIAG</FONT>>]
  X04tB0000000KAf4IAG [label=<ESBaseStylesLWC 1.0.0.2<BR/><FONT POINT-SIZE="8">033B0000000buUjIAI</FONT><BR/><FONT POINT-SIZE="8">04tB0000000KAf4IAG</FONT>>]
  X04tB0000000KAfJIAW [label=<ESSpaceMgmtLWC 1.0.0.3<BR/><FONT POINT-SIZE="8">033B0000000buUtIAI</FONT><BR/><FONT POINT-SIZE="8">04tB0000000KAfJIAW</FONT>>]
  // Paths
  X04tB0000000KAekIAG->X04tB0000000KAefIAG
  X04tB0000000KAf4IAG->X04tB0000000KAefIAG
  X04tB0000000KAf4IAG->X04tB0000000KAekIAG
  X04tB0000000KAfJIAW->X04tB0000000KAefIAG
  X04tB0000000KAfJIAW->X04tB0000000KAekIAG
}

To render the output as SVG use the instructions at Render the SVG as dependency graph in an image. Following is an example of a package dependency graph with version details.

Graph

Build and Debug

There are two options to A) build and deploy the sfdx plugin or B) build the node.js application for local testing. Option B is interesting only if you want to maintain different versions, one deployed as SFDX plugin and another one for development testing. Build time is equally fast for both options.

A Build the SFDX plugin

  1. Uninstall the existing plugin
sfdx plugins:uninstall dependencies-cli
  1. Build and install the plugin from the project root folder
sfdx plugins:link ./

Optionally: in case of errors due to missing dependencies, install them with npm

npm install <package> --save
  1. Test the plugin
sfdx dependency

B Build the node.js application for local testing

  1. Run yarn clean in the project root folder
yarn run clean

Optionally: run yarn install in case you used npm package installer to manually install packages

yarn install
  1. Build the code using npm run scripts in the project root folder
npm run-script build
  1. Test your changes with a local bin/run script
bin/run dependency

C Debug the SFDX plugin (with VSCode)

  1. Run the plugin in debug mode
sfdx dependency:<command> --dev-suspend
  1. Attach VS Code Debugger to ws://127.0.0.1:9229/<PID>

D Debug the node.js application locally

  1. Before linking the plugin to Salesforce CLI run
NODE_OPTIONS=--inspect-brk bin/run dependency
  1. Attach VS Code Debugger to ws://127.0.0.1:9229/<PID>

Troubleshooting

ERROR running dependency:component:componentizer: sObject type 'MetadataComponentDependency' is not supported.

Explanation: This error indicates that your org does not have the metadata dependency API enabled. The API is still in beta for production orgs as of release Summer`19.

Resolution: Contact your Salesforce support and provide them the to work with. Salesforce support should enable the Enable MetadataComponentDependency API perm for your org.

ERROR running dependency:component:componentizer: No AuthInfo found for name

Explanation: This error indicates that you forgot to provide the -u flag needed for the command execution. The SFDX plugin attempts to use the default user id but requires dedicated authentication info.

Resolution: Supply the -u <userId> option with the command.

ERROR dependencyGraph::retrieveRecords().err sObject type 'CustomField' is not supported.

Explanation: This error happens with certain orgs where not all metadata object types are supported for query with the tooling API. The error is not fatal and a graph will be produced to STDOUT including all supported metadata types. The error logged to STDERR includes details for the query in question, for example:

dependencyGraph::retrieveRecords().query SELECT Id, TableEnumOrId FROM CustomField c WHERE c.Id In ('00h0M00000FoNWnQAN','00h30000000i0DcAAI','00h300000012QrnAAE','00h300000012oWtAAI','00h3000000133AJAAY','00h30000001MDH9AAO','00h30000001OIu3AAG','00h30000001OKZ1AAO','00h30000001OLxMAAW','00h30000000gnhbAAA') limit 2000

Resolution: Contact support to investigate the settings for your org and enable the failing metadata type queries.

More Repositories

1

postman-salesforce-apis

Salesforce API Postman Collection
1,071
star
2

salesforcedx-vscode

Salesforce Extensions for VS Code
TypeScript
949
star
3

aura

This project is archived, please see the readme for additional resources.
JavaScript
676
star
4

scrollerjs

A JavaScript library that helps you build performant UI components for the web.
JavaScript
637
star
5

phoenix

Java
560
star
6

SalesforceMobileSDK-iOS

iOS SDK for Salesforce
Objective-C
520
star
7

cli

Salesforce CLI
477
star
8

dataloader

Salesforce Data Loader
Java
440
star
9

SFDX-Data-Move-Utility

SFDMU is a cutting-edge Salesforce data migration tool for seamless org population from other orgs or CSV files. It handles all CRUD operations on multiple related objects in one go.
TypeScript
405
star
10

SalesforceMobileSDK-Android

Android SDK for Salesforce
Java
313
star
11

wsc

Java
266
star
12

mobile-ui-elements

Custom elements to build beautiful mobile applications on salesforce.
JavaScript
247
star
13

idecore

The core plug-ins for the Force.com IDE
Java
238
star
14

sfdx-scanner

HTML
215
star
15

EMP-Connector

A simplified cometd connector for Enterprise Messaging Platform
Java
185
star
16

CustomMetadataLoader

Tool to help users bulk create and update custom metadata records in salesforce.com from a CSV file.
Apex
161
star
17

b2b-commerce-on-lightning-quickstart

Shell
157
star
18

sfdx-core

TypeScript
151
star
19

force-dot-com-esapi

Enterprise Security API for the Apex language on the Force.com platform.
Apex
129
star
20

Analytics-Cloud-Dataset-Utils

Friendly utility to load your on-prem data, whether large or small, to Einstein Analytics Datasets, with useful features such as autoloading, dataflow control and dataset inspection.
JavaScript
129
star
21

SalesforceCanvasFrameworkSDK

Java
122
star
22

LightningTestingService

JavaScript
122
star
23

sfdx-simple

Apex
116
star
24

quiz-host-app

Multiplayer quiz app built on Salesforce technology (host app)
Apex
108
star
25

SalesforcePy

An absurdly simple package for making Salesforce Rest API calls.
Python
106
star
26

sfdx-travisci

Apex
98
star
27

Data-Migration-Tool

Java
98
star
28

ConnectApiHelper

Helper class that makes it easier to post Chatter @-mentions, rich text, and inline images with Apex code.
Apex
93
star
29

RecordViewer

Record Viewer - UI API + Node.js Sample App
JavaScript
86
star
30

salesforcedx-templates

Salesforce Templates Node Library
TypeScript
79
star
31

SFDX-Data-Move-Utility-Desktop-App

This repository contains the special Desktop GUI Application, that will help you to prepare and execute data migration packages using the SFDMU Plugin.
TypeScript
77
star
32

sfdx-plugin-generate

TypeScript
73
star
33

salesforcedx-docker

The official Dockerfile for Salesforce DX
JavaScript
72
star
34

ApexUnit

ApexUnit is a powerful continuous integration tool for the Force.com platform
Java
71
star
35

SalesforceMobileSDK-Shared

JavaScript
68
star
36

cinnamon

Cinnamon is a Force.com app that enables you to build and run Selenium tests to validate custom UI pages with Visualforce/Javascript in your Salesforce org.
Apex
67
star
37

commerce-on-lightning-components

Commerce on Lightning out-of-the-box component source code for reference and educational purposes
JavaScript
67
star
38

SalesforceMobileSDK-Samples

Samples for working with the Salesforce Mobile SDK
C
65
star
39

commerce-on-lightning

An SFDX Plugin to setup a B2C or B2B Store
TypeScript
64
star
40

WSDL2Apex

Apex
62
star
41

salesforce-alm

A read-only snapshot of the salesforce-alm plugin known as the "toolbelt".
TypeScript
61
star
42

devops-center-feedback

61
star
43

SlidingCarousel

A tool used to create the onboarding experience for Salesforce1's hybrid application on iOS.
Objective-C
59
star
44

LightningFlowComponents

⚑ A collection of sample Lightning Components that can be used to enhance Salesforce Lightning Flow.
JavaScript
58
star
45

source-deploy-retrieve

JavaScript toolkit for working with Salesforce metadata.
TypeScript
55
star
46

PerlKoans

Perl
51
star
47

go-soql

Golang tag library to generate SOQL queries
Go
51
star
48

java-sdk

NO LONGER MAINTAINED: Database.com SDK for Java
Java
47
star
49

SalesforceMobileSDK-Templates

Kotlin
46
star
50

SalesforceMobileSDK-ReactNative

Objective-C
46
star
51

user-access-visualization

Apex
46
star
52

AuraEnabledScanner

JavaScript
45
star
53

SalesforceMobileSDK-CordovaPlugin

Cordova plugin for the Salesforce Mobile SDK
Java
45
star
54

sfdx-analytics

Einstein Analytics sample application templates
JavaScript
44
star
55

sfdx-jenkins-org

Jenkins example with org development
Apex
44
star
56

cli-packages

TypeScript
43
star
57

lwc-dev-server-feedback

LWC Local Development
43
star
58

LWC-Mobile-Samples

Mobile sample applications and code for LWC development
JavaScript
42
star
59

isvte-sfdx-plugin

TypeScript
42
star
60

SalesforceCanvasJavascriptSDK

A JavaScript SDK used to integrate applications with the Force.com Canvas framework
JavaScript
42
star
61

OrgMonitor

JavaScript
41
star
62

Salesforce1-Dev-Guide-Setup-Package

40
star
63

sfdx-bitbucket-package

Bitbucket Pipelines examples with Package development
Apex
39
star
64

project-force

Reference implementation app for Feature Management.
Apex
37
star
65

schemas

Salesforce DX Schemas
JavaScript
36
star
66

Einstein-GPT-for-Developers

Einstein GPT For Developers
36
star
67

salesforcedx-actions

(Unofficial) GitHub Actions for SalesforceDX using the Salesforce CLI
Shell
34
star
68

aura-note

JavaScript
34
star
69

lightning-language-server

LWC and Aura Language Servers - shipped as part of the Salesforce VSCode Extensions
JavaScript
33
star
70

distributions

Low-level primitives for collapsed Gibbs sampling in python and C++
C++
33
star
71

apex-tmLanguage

Salesforce Apex Language syntax grammar used for colorization
TypeScript
32
star
72

Salesforce-CDP-jdbc

JDBC driver to connect to Salesforce CDP.
Java
32
star
73

sfdx-dev-packages

TypeScript
30
star
74

sfdx-gitlab-org

GitLab Pipelines example with org development
Apex
30
star
75

code-builder-feedback

This repository is used to collect feedback for the Code Builder beta.
29
star
76

eslint-plugin-aura

Salesforce Lightning (Aura) specific linting rules for ESLint
JavaScript
27
star
77

git2gus

A Github application to keep issues in sync with Agile Accelerator
JavaScript
27
star
78

salesforcedx-vscode-slds

TypeScript
26
star
79

sfdx-bitbucket-org

Bitbucket Pipelines examples with org development
Apex
26
star
80

lwc-builder

VSCode Extension to kickstart Lightning Web Component development.
TypeScript
26
star
81

sfdx-circleci

Apex
24
star
82

ServiceSDK-iOS

Salesforce Embedded Service SDK for iOS
23
star
83

dx-empty

Template repository representing the empty file system structure for a new Salesforce DX project.
JavaScript
23
star
84

SalesforceMobileSDK-Package

JavaScript
22
star
85

soql-tooling

SOQL Language Tooling features including the Language Server and Query Builder UI.
TypeScript
22
star
86

RecordViewerNative

Record Viewer Native - UI API + React Native Sample App
JavaScript
21
star
87

salesforce-deskcom-api

A lightweight, flexible library for desk.com APIv2, it supports basic auth and OAuth as authentication methods and is written to be auto discoverable.
Ruby
21
star
88

sfdx-gitlab-package

Apex
20
star
89

lwc-builder-ui

JavaScript
20
star
90

almond

Native Force.com Learning Management Application
Apex
20
star
91

SiteCrawler

This is a Java library which can be used to crawl the content of some of web properties (www.salesforce.com, blogs.salesforce.com for example). It supports dynamic scaling (depending on available machine power (CPU, RAM) and network capacity) out of the box. It also has a Plugin structure, which allows others to write code (plugins) that act on the crawled pages.
Java
20
star
92

devops-center-roadmap

19
star
93

lwc-dev-mobile

TypeScript
19
star
94

sfdx-jenkins-package

Apex
19
star
95

source-tracking

JavaScript library for tracking local and remote Salesforce metadata changes.
TypeScript
19
star
96

df17-ant-to-sfdx

Metadata repository demonstrating move from Ant Migration Tools to the Salesforce CLI
Apex
19
star
97

salesforce-datacom-api-java-client

Easy-to-use and efficient Java client library for accessing Data.com APIs using JSON[XML] and OAuth 2.0
Java
19
star
98

commerce-extensibility

Apex
18
star
99

codey-midnight

Dark theme for VS Code configured for accessibility and Salesforce development
18
star
100

salesforcedx-apex

Salesforce Apex Node Library
TypeScript
18
star