Salesforce-Data-Treecipe is a Visual Studio Code extension designed to streamline the process of generating production-like data during development in order to support building Quality in.
This extension auto-generates a recipe yaml file based on the running, local project structure. Said differently, what is already in the "source" for the project.
From the generated "Fake-Data Generating YAML Files", additional commands can be used following the recipe generation to build Collections API datasets that can be committed and reused as needed.
Users have two choices of "Fake Data" implementations:
- faker-js - Can handle simple to complicated data generation and uploads
- snowfakery - All of the above and way more for advanced data generation scenarios
- Prerequisites for Snowfakery
- VS Code Extension Installation
- "How To" YouTube Walkthroughs:
- Get started by walking through the below commands
- VIDEO WALKTHROUGHS
- Troubleshooting, Exception Handling, and Reporting Bugs
- Contributing
- License
- Install Snowfakery CLI
If using snowfakery as Faker service instead of faker-js.
"faker-js" can be natively installed with VS Code extensions and does not require machine setup steps.
- Open Visual Studio Code.
- Go to the Extensions panel and search for Salesforce-Data-Treecipe.
- Click Install.
Note: press Ctrl+Shift+P
(or Cmd+Shift+P
on macOS) to open the Command Palette.
- Initiate Configuration File
- Generate Treecipe
- Run Snowfakery by Recipe(Treecipe) to create FakeDataSet
- Insert Data Set by Directory
This command initiates the creation of a configuration file that is required before using other features of the extension.
The command creates a root directory folder called "treecipe" and within it a configuration file called "treecipe.config.json".
This file is auto generated based on the field configurations detailed selection made when prompted "Select objects directory".
The end result treecipe.config.json file is expected to look like the below:
- salesforceObjectsPath - will vary based on selected directory in your VS Code workspace
- dataFakerService - can be 'snowfakery' or 'faker-js'
{
"salesforceObjectsPath": "./force-app/main/default/objects/",
"dataFakerService": "faker-js"
}
- Select "Salesforce Treecipe: Initiate Configuration File" from the command palette.
- You will be prompted to type the source directory in your codebase where Salesforce objects are stored in source format. Begin typing the folder and the directories will auto-filter to match directories based on the entered text.
Once the configuration file is generated, you can begin using the Generate Treecipe command.
This command generates a Treecipe, a structured representation of your Salesforce data, based on your treecipe configuration and the objects directory it is pointed to.
It parses the "salesforceObjectsPath" directory path that was provided when running the "Initiate Configuration File" command above, and then generates a yaml file of objects and associated fields found in that directory.
As part of this yaml file generation there are some items to be aware of:
- "TODO" items: Review sections marked with "TODO" before generating fake data. These mark areas that need clarification or input.
- Handling of field files without xml markup: OOTB fields (e.g., AccountNumber, Name) lack XML detail. Some (like Name) need faker values manually added.
- Record Type Picklist, Dependent Picklist, Multiselect Picklist Selections: Object folders are parsed to detect record types and relevant picklist faker options.
NOTE:
If this command is run before "Initiate Configuration File" is completed, a warning will appear in VS Code prompting to run it.
- Generate Treecipe requires a valid configuration file and selected Salesforce objects directory.
This command prompts the user to select an existing recipe(Treecipe) file to generate fake data from.
With the selection made, the snowfakery CLI will execute against the yaml file and produce json structured, production-like data which is then converted for usage with Salesforce Collection Api
This command prompts the user for the following items:
-
Select a pre-existing "dataset" directory with expected Collections-Api structure files
-
Enter name of already locally authenticated Salesforce alias (DO NOT USE PRODUCTION ORG!!!)
-
Select "ALL OR NONE" option.
- "false" keeps successfully inserted records
- "true" rolls back all inserted records
initiatetreecipe.mp4
Generate Treecipe based on treecipe.config.jcon (keep an eye out for OOTB fields and "REMOVE ME" lines)
generatetreecipe.mp4
generateDataByTreecipe.mp4
insertdatasetsbydirectory_compressed.mp4
See below for troubleshooting when specific commands are not working:
-
Salesforce Treecipe - Generate Treecipe - generateRecipeFromConfigurationDetail:
- Ensure "Initiate Configuration File" was successfully run
- Ensure path in treecipe.config.json uses forward-slashes
- Ensure "defaultFakerService" is set to "snowfakery"
-
Salesforce Treecipe: Initiate Configuration File - initiateTreecipeConfigurationSetup:
- Ensure expected project directory was selected
NOTE:
All commands are wrapped in try-catch and will prompt a "Report a Bug" dialog. This generates a GitHub Issue template with a stack trace.
exceptionhanlding.mp4
This project and codebase will be open-sourced shortly :)
This extension is licensed under the MIT License.
Snowfakery is a tool for generating synthetic data. This document provides instructions for installing and using the Snowfakery CLI on any operating system.
-
Python 3.8+ is required:
python --version
-
pip (Python package manager): https://pip.pypa.io/en/stable/installation/
pip install snowfakery
snowfakery --version
snowfakery generate <path_to_your_snowfakery_recipe>
Official documentation: https://snowfakery.readthedocs.io/
pip uninstall snowfakery