Skip to content

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 what is already in the source object metadata xml of your project.

License

Notifications You must be signed in to change notification settings

jdschleicher/Salesforce-Data-Treecipe

Repository files navigation

Salesforce-Data-Treecipe

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

Table of Contents


Prerequisites for Snowfakery

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.

  1. Install Snowfakery CLI

VS Code Extension Installation

  1. Open Visual Studio Code.
  2. Go to the Extensions panel and search for Salesforce-Data-Treecipe.
  3. Click Install.

"How To" YouTube Walkthroughs:


Get started by walking through the below commands

Note: press Ctrl+Shift+P (or Cmd+Shift+P on macOS) to open the Command Palette.

  1. Initiate Configuration File
  2. Generate Treecipe
  3. Run Snowfakery by Recipe(Treecipe) to create FakeDataSet
  4. Insert Data Set by Directory

1. Salesforce Treecipe: Initiate Configuration File

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"
}

How It Works:

  • 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.

Corresponding Video:

https://github.com/jdschleicher/Salesforce-Data-Treecipe/blob/main/README.md#initiate-treecipe-configuration-with-expected-objects-directory


2. Salesforce Treecipe: Generate Treecipe

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.

Prerequisite:

  • Generate Treecipe requires a valid configuration file and selected Salesforce objects directory.

Corresponding Video:

https://github.com/jdschleicher/Salesforce-Data-Treecipe/blob/main/README.md#generate-treecipe-based-on-treecipeconfigjcon--keep-an-eye-out-for-ootb-fields-and-remove-me-lines-


3. Salesforce Treecipe: Run Faker by Recipe

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

Corresponding Video:

https://github.com/jdschleicher/Salesforce-Data-Treecipe/blob/main/README.md#run-snowfakery-by-existing-recipe-yaml-file


4. Salesforce Treecipe: Insert Data Set by Directory

This command prompts the user for the following items:

  1. Select a pre-existing "dataset" directory with expected Collections-Api structure files

  2. Enter name of already locally authenticated Salesforce alias (DO NOT USE PRODUCTION ORG!!!)

  3. Select "ALL OR NONE" option.

    • "false" keeps successfully inserted records
    • "true" rolls back all inserted records

VIDEO WALKTHROUGHS

Initiate Treecipe Configuration with expected Objects directory

initiatetreecipe.mp4

Generate Treecipe based on treecipe.config.jcon (keep an eye out for OOTB fields and "REMOVE ME" lines)

generatetreecipe.mp4

Run Snowfakery by existing recipe yaml file

generateDataByTreecipe.mp4

Insert Data Set by Directory

insertdatasetsbydirectory_compressed.mp4

Troubleshooting, Exception Handling, and Reporting Bugs

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.

Video Walkthrough:

exceptionhanlding.mp4

Contributing

This project and codebase will be open-sourced shortly :)


License

This extension is licensed under the MIT License.


Install Snowfakery CLI

Snowfakery CLI Installation and Usage

Overview

Snowfakery is a tool for generating synthetic data. This document provides instructions for installing and using the Snowfakery CLI on any operating system.

Prerequisites

Installation

pip install snowfakery

Verify the Installation

snowfakery --version

Usage (Without Salesforce Data Treecipe Extension)

snowfakery generate <path_to_your_snowfakery_recipe>

Official documentation: https://snowfakery.readthedocs.io/

Uninstalling Snowfakery

pip uninstall snowfakery

About

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 what is already in the source object metadata xml of your project.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published