{"id":13668422,"url":"https://github.com/k-capehart/kc-sf-plugin","last_synced_at":"2025-09-12T06:46:30.956Z","repository":{"id":240243723,"uuid":"800572597","full_name":"k-capehart/kc-sf-plugin","owner":"k-capehart","description":"a collection of custom commands for the sf cli, including automated trigger framework generation","archived":false,"fork":false,"pushed_at":"2025-08-22T14:11:46.000Z","size":1587,"stargazers_count":11,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-22T16:37:16.408Z","etag":null,"topics":["salesforce","sf-cli","sfdx","sfdx-plugin"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/kc-sf-plugin","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/k-capehart.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-05-14T15:34:30.000Z","updated_at":"2025-08-22T14:11:43.000Z","dependencies_parsed_at":"2024-05-30T20:24:41.184Z","dependency_job_id":"0534af4e-6720-40b2-88d1-eae3ed354551","html_url":"https://github.com/k-capehart/kc-sf-plugin","commit_stats":null,"previous_names":["k-capehart/kc-sf-plugin"],"tags_count":36,"template":false,"template_full_name":null,"purl":"pkg:github/k-capehart/kc-sf-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-capehart%2Fkc-sf-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-capehart%2Fkc-sf-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-capehart%2Fkc-sf-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-capehart%2Fkc-sf-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/k-capehart","download_url":"https://codeload.github.com/k-capehart/kc-sf-plugin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-capehart%2Fkc-sf-plugin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271732362,"owners_count":24811309,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-23T02:00:09.327Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["salesforce","sf-cli","sfdx","sfdx-plugin"],"created_at":"2024-08-02T08:00:34.029Z","updated_at":"2025-09-12T06:46:30.948Z","avatar_url":"https://github.com/k-capehart.png","language":"TypeScript","funding_links":[],"categories":["Community supported plugins"],"sub_categories":[],"readme":"# kc-sf-plugin\n\n[![NPM](https://img.shields.io/npm/v/kc-sf-plugin.svg?label=kc-sf-plugin)](https://www.npmjs.com/package/kc-sf-plugin) [![Downloads/week](https://img.shields.io/npm/dw/kc-sf-plugin.svg)](https://npmjs.org/package/kc-sf-plugin) [![License](https://img.shields.io/badge/License-BSD%203--Clause-brightgreen.svg)](https://github.com/k-capehart/kc-sf-plugin/blob/main/LICENSE)\n\nThis plugin is bundled with the [Salesforce CLI](https://developer.salesforce.com/tools/sfdxcli). For more information on the CLI, read the [getting started guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_intro.htm).\n\n## Contents\n\n- [Install](#install)\n- [Trigger-Framework](#trigger-framework)\n- [List of Commands](#list-of-commands)\n- [Build](#build)\n\n## Install\n\n```bash\nsf plugins install kc-sf-plugin@x.y.z\n```\n\n## Trigger-Framework\n\nThe trigger-framework command auto generates components used in relation to Apex Triggers.\n\nFirst, use the `--init` flag to initialize the framework for a given template. This generates files that should only be created once, like interfaces or custom setting objects.\n\nAfter initializing, use the `--sobject` flag to add a given object to the framework.\n\n![Demo of kc trigger-framework command creating triggers and classes](./assets/trigger-framework.gif)\n\nThe `--template` flag is used to choose which template to generate the apex code from. The available templates are:\n\n- 1 (default)\n\n  - Based on: https://github.com/kevinohara80/sfdc-trigger-framework\n    - Fork with extra features: https://github.com/k-capehart/sfdc-trigger-framework\n  - A Custom Setting called BypassAutomation\\_\\_c with checkbox fields for Salesforce objects\n    - Allows disabling of triggers on a per object basis either globally or for a given user\n  - Extendable Apex class for trigger handler functionality: TriggerHandler\n  - Apex trigger, Handler, and Helper class for a Salesforce object\n  - Apex test classes\n\n- 2\n\n  - Based on: https://github.com/trailheadapps/apex-recipes\n  - 2 Custom Metadata objects: Metadata_Driven_Trigger and Disabled_For\n    - Allows defining the order of execution for trigger handlers, and disable triggers either globally or for a given user\n  - Extendable Apex classes for trigger handler functionality: TriggerHandler, MetadataTriggerHandler, and MetadataTriggerService\n  - Apex trigger, Handler, and helper class for a Salesforce object\n\nIf you want to create a custom template, then use the `--custom-template` flag. The value given to the flag should be the path to a directory containing templates for classes, triggers, objects, etc. The directory should contain a `init.json` and `sobject.json` that provide instructions on which files to use. There are 3 required fields for each template:\n\n- `name`: The API name for the component (i.e. `TriggerHandler` or `Enabled__c`)\n- `fileType`: The file extension for the component (i.e. `.cls` or `.field-meta.xml`)\n- `targetDir`: The file path within a salesforce dx project where the component should be created (i.e. `/classes/`, `/objects/Metadata_Driven_Trigger__mdt/fields/`)\n\n`init.json` is used with the `--init` flag. `sobject.json` is used with the `--sobject` flag.\n\nFor example, imagine the following JSON file is stored at the relative path of `templates/sobject.json`. It is assumed that within this directory are also 5 other files called `BypassCustomField.txt`, `SObjectTrigger.txt`, `SObjectTriggerHandler.txt`, `SObjectTriggerHelper.txt`, and `SObjectTriggerHelper_Test.txt`. The `{{sobject}}` token is replaced at runtime with the value given in the `--sobject` flag.\n\n```json\n{\n  \"BypassCustomField.txt\": {\n    \"name\": \"{{sobject}}__c\",\n    \"fileType\": \".field-meta.xml\",\n    \"targetDir\": \"/objects/BypassAutomation__c/fields/\"\n  },\n  \"SObjectTrigger.txt\": {\n    \"name\": \"{{sobject}}Trigger\",\n    \"fileType\": \".trigger\",\n    \"targetDir\": \"/triggers/\"\n  },\n  \"SObjectTriggerHandler.txt\": {\n    \"name\": \"{{sobject}}TriggerHandler\",\n    \"fileType\": \".cls\",\n    \"targetDir\": \"/classes/\"\n  },\n  \"SObjectTriggerHelper.txt\": {\n    \"name\": \"{{sobject}}Helper\",\n    \"fileType\": \".cls\",\n    \"targetDir\": \"/classes/\"\n  },\n  \"SObjectTriggerHelper_Test.txt\": {\n    \"name\": \"{{sobject}}Helper_Test\",\n    \"fileType\": \".cls\",\n    \"targetDir\": \"/classes/\"\n  }\n}\n```\n\nRunning the command: `sf kc trigger-framework --custom-template templates/ --sobject Account` will create 5 files:\n\n- Account\\_\\_c.field-meta.xml\n- AccountTrigger.trigger\n- AccountTriggerHandler.cls\n- AccountTriggerHelper.cls\n- AccountTriggerHelper_Test.cls\n\nFor more template examples: https://github.com/k-capehart/kc-sf-plugin/tree/main/src/templates/\n\n## List of Commands\n\n\u003c!-- commands --\u003e\n* [`sf kc diff`](#sf-kc-diff)\n* [`sf kc trigger-framework`](#sf-kc-trigger-framework)\n* [`sf kc update-api`](#sf-kc-update-api)\n\n## `sf kc diff`\n\nPreview a retrieval and deploy to see what will be retrieved from the org, the potential conflicts, and the ignored files.\n\n```\nUSAGE\n  $ sf kc diff -o \u003cvalue\u003e [--json] [--flags-dir \u003cvalue\u003e] [--concise]\n\nFLAGS\n  -o, --target-org=\u003cvalue\u003e  (required) Login username or alias for the target org.\n      --concise             Omits files that are forceignored.\n\nGLOBAL FLAGS\n  --flags-dir=\u003cvalue\u003e  Import flag values from a directory.\n  --json               Format output as json.\n\nDESCRIPTION\n  Preview a retrieval and deploy to see what will be retrieved from the org, the potential conflicts, and the ignored\n  files.\n\n  You must run this command from within a project that has source tracking.\n\n  The command outputs a table that describes the difference between your local project and an org. It is equivalent to\n  running both the \"sf project retrieve preview\" and \"sf project deploy preview\" commands.\n\nEXAMPLES\n  View differences between local org and an org with the alias \"my-org\"\n  $ sf kc diff --target-org my-org\n  View differences between local org and the default org, omitting ignored files\n  $ sf kc diff --concise\n\nFLAG DESCRIPTIONS\n  -o, --target-org=\u003cvalue\u003e  Login username or alias for the target org.\n\n    Overrides your default org.\n\n  --concise  Omits files that are forceignored.\n\n    Ignore files by placing them in your .forceignore and using this flag.\n```\n\n_See code: [src/commands/kc/diff.ts](https://github.com/k-capehart/kc-sf-plugin/blob/1.4.19/src/commands/kc/diff.ts)_\n\n## `sf kc trigger-framework`\n\nGenerate apex trigger frameworks based on templates.\n\n```\nUSAGE\n  $ sf kc trigger-framework [--json] [--flags-dir \u003cvalue\u003e] [-d \u003cvalue\u003e] [-i] [-s \u003cvalue\u003e...] [-t 1|2] [--custom-template\n    \u003cvalue\u003e]\n\nFLAGS\n  -d, --target-dir=\u003cvalue\u003e       [default: force-app/main/default] The target directory for your salesforce project.\n  -i, --init                     Initialize the trigger framework for the given template.\n  -s, --sobject=\u003cvalue\u003e...       The name of the SObject that the trigger and classes will be created for.\n  -t, --template=\u003coption\u003e        The template that should be used to generate the trigger framework.\n                                 \u003coptions: 1|2\u003e\n      --custom-template=\u003cvalue\u003e  The directory in which the custom templates are located. View docs for more information\n                                 on creating templates: https://github.com/k-capehart/kc-sf-plugin\n\nGLOBAL FLAGS\n  --flags-dir=\u003cvalue\u003e  Import flag values from a directory.\n  --json               Format output as json.\n\nDESCRIPTION\n  Generate apex trigger frameworks based on templates.\n\n  Given an SObject, creates a Trigger and related components.\n\n  Use the `--init` flag to initialize the framework, then the `--sobject` flag to create triggers based on the\n  framework.\n\nEXAMPLES\n  Initialize a trigger framework using template-1.\n  $ sf kc trigger-framework --template 1 --init\n  Create a new trigger and related components for the Account and Contact object using template-1.\n  $ sf kc trigger-framework --template 1 --sobject Account --sobject Contact\n  Create a new trigger and related components with a custom template by providing the path to the locally stored templates.\n  $ sf kc trigger-framework --custom-template templates/ --sobject Account\n```\n\n_See code: [src/commands/kc/trigger-framework.ts](https://github.com/k-capehart/kc-sf-plugin/blob/1.4.19/src/commands/kc/trigger-framework.ts)_\n\n## `sf kc update-api`\n\nUpdate the API version of Apex classes, triggers, and flows.\n\n```\nUSAGE\n  $ sf kc update-api -t classes|triggers|flows... -v \u003cvalue\u003e [--json] [--flags-dir \u003cvalue\u003e] [-d \u003cvalue\u003e]\n\nFLAGS\n  -d, --target-dir=\u003cvalue\u003e   [default: force-app/main/default] The target directory for your salesforce project.\n  -t, --type=\u003coption\u003e...     (required) The component type whose API version should be updated.\n                             \u003coptions: classes|triggers|flows\u003e\n  -v, --api-version=\u003cvalue\u003e  (required) The minimum required API version that components should satisfy.\n\nGLOBAL FLAGS\n  --flags-dir=\u003cvalue\u003e  Import flag values from a directory.\n  --json               Format output as json.\n\nDESCRIPTION\n  Update the API version of Apex classes, triggers, and flows.\n\n  Parse through a SFDX project and update the API version for Apex classes, triggers and flows to a specified version.\n  The API version must be a valid version that is not deprecated.\n\nEXAMPLES\n  Update all apex classes and triggers to be at least version 61.0.\n  - sf kc update-api --type classes --type triggers --api-version 61.0\n\nFLAG DESCRIPTIONS\n  -v, --api-version=\u003cvalue\u003e  The minimum required API version that components should satisfy.\n\n    Override the api version used for api requests made by this command\n```\n\n_See code: [src/commands/kc/update-api.ts](https://github.com/k-capehart/kc-sf-plugin/blob/1.4.19/src/commands/kc/update-api.ts)_\n\u003c!-- commandsstop --\u003e\n\n## Build\n\nTo build the plugin locally, make sure to have yarn installed and run the following commands:\n\n```bash\n# Clone the repository\ngit clone git@github.com:k-capehart/kc-sf-plugin\n\n# Install the dependencies and compile\nyarn \u0026\u0026 yarn build\n```\n\nTo use your plugin, run using the local `./bin/dev` or `./bin/dev.cmd` file.\n\n```bash\n# Run using local run file.\n./bin/dev kc diff\n```\n\nThere should be no differences when running via the Salesforce CLI or using the local run file. However, it can be useful to link the plugin to do some additional testing or run your commands from anywhere on your machine.\n\n```bash\n# Link your plugin to the sf cli\nsf plugins link .\n# To verify\nsf plugins\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk-capehart%2Fkc-sf-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fk-capehart%2Fkc-sf-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk-capehart%2Fkc-sf-plugin/lists"}