From 2608ec9c16f6136c7f42353eac421ba9ee5ed802 Mon Sep 17 00:00:00 2001 From: "Kyle Capehart (Huntersville)" Date: Thu, 30 May 2024 13:39:16 -0400 Subject: [PATCH] feat: streamline creating custom templates --- README.md | 50 +++++-- messages/kc.trigger-framework.md | 10 +- src/commands/kc/trigger-framework.ts | 40 +++--- src/templates/template-1/init.json | 15 +++ src/templates/template-1/sobject.json | 23 ++++ src/utils/triggerFactory.ts | 149 +++++++++------------ src/utils/types.ts | 10 ++ test/commands/kc/trigger-framework.nut.ts | 35 ++++- test/commands/kc/trigger-framework.test.ts | 33 +++++ test/utils/triggerFactory.nut.ts | 42 ++---- 10 files changed, 256 insertions(+), 151 deletions(-) create mode 100644 src/templates/template-1/init.json create mode 100644 src/templates/template-1/sobject.json create mode 100644 test/commands/kc/trigger-framework.test.ts diff --git a/README.md b/README.md index 3772f34..8a24537 100644 --- a/README.md +++ b/README.md @@ -24,20 +24,50 @@ The `--template` flag is used to choose which template to generate the apex code - An extendable Apex Trigger Handler virtual class: https://github.com/k-capehart/sfdc-trigger-framework - A Custom Setting called BypassAutomation\_\_c - A checkbox field on BypassAutomation for the given Salesforce object - - An Apex trigger - - An Apex handler class that extends the virtual class, and uses the BypassAutomation\_\_c object to determine if logic should be skipped + - An Apex trigger that calls a handler class + - An Apex handler class that extends the virtual class and uses the BypassAutomation\_\_c object to determine if logic should be skipped - An Apex helper class - An Apex test class for the helper class -If you want to override a given template, then use the `--template-override` flag. The value given to the flag should be the path to a directory containing identically named files for a given template. -For example, to override template 1: +If 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, and/or fields. The directory should contain a `init.json` and `sobject.json` that provide instructions on which files to use, what their final name should be, and what type of file they are. `init.json` is used with the `--init` flag. `sobject.json` is used with the `--sobject` flag. + +For 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 with the value given in the `--sobject` flag. + +```json +{ + "BypassCustomField.txt": { + "type": "field", + "name": "{{sobject}}__c", + "object": "BypassAutomation__c" + }, + "SObjectTrigger.txt": { + "type": "trigger", + "name": "{{sobject}}Trigger" + }, + "SObjectTriggerHandler.txt": { + "type": "class", + "name": "{{sobject}}TriggerHandler" + }, + "SObjectTriggerHelper.txt": { + "type": "class", + "name": "{{sobject}}Helper" + }, + "SObjectTriggerHelper_Test.txt": { + "type": "class", + "name": "{{sobject}}Helper_Test" + } +} +``` + +Running the command: `sf kc trigger-framework --custom-template templates/ --sobject Account` will create a 5 files: + +- Account\_\_c.field-meta.xml +- AccountTrigger.trigger +- AccountTriggerHandler.cls +- AccountTriggerHelper.cls +- AccountTriggerHelper_Test.cls -1. Copy and paste the contents of this folder into a local directory, such as `templates/`: https://github.com/k-capehart/kc-sf-plugin/tree/main/src/templates/template-1 -2. Modify the content of the text files according to your specific needs - - Note that `{{sobject}}` is a token that will be replaced with the given Salesforce Object name given in the `--sobject` flag -3. Run the commands: -
`$ sf kc trigger-framework --template 1 --template-override templates/ --init` -
`$ sf kc trigger-framework --template 1 --template-override templates/ --sobject Account` +For more template examples: https://github.com/k-capehart/kc-sf-plugin/tree/main/src/templates/ ## Commands diff --git a/messages/kc.trigger-framework.md b/messages/kc.trigger-framework.md index 27e994b..5552113 100644 --- a/messages/kc.trigger-framework.md +++ b/messages/kc.trigger-framework.md @@ -12,15 +12,15 @@ Use the `--init` flag to initialize the framework, then the `--sobject` flag to Initialize a trigger framework using template-1. -<%= config.bin %> <%= command.id %> --template 1 --template-override templates/ --init +<%= config.bin %> <%= command.id %> --template 1 --init Create a new trigger and related components for the Account and Contact object using template-1. <%= config.bin %> <%= command.id %> --template 1 --sobject Account --sobject Contact -Create a new trigger and related components by overriding template-1 using files located at templates/. +Create a new trigger and related components with a custom template by providing the path to the locally stored templates. -<%= config.bin %> <%= command.id %> --template 1 --template-override templates/ --sobject Account +<%= config.bin %> <%= command.id %> --custom-template templates/ --sobject Account # flags.target-dir.summary @@ -34,9 +34,9 @@ The name of the SObject that the trigger and classes will be created for. The template that should be used to generate the trigger framework. -# flags.template-override.summary +# flags.custom-template.summary -The directory in which the custom templates are located. +The directory in which the custom templates are located. View docs for more information on creating templates: https://github.com/k-capehart/kc-sf-plugin # flags.init.summary diff --git a/src/commands/kc/trigger-framework.ts b/src/commands/kc/trigger-framework.ts index efb3f87..7113842 100644 --- a/src/commands/kc/trigger-framework.ts +++ b/src/commands/kc/trigger-framework.ts @@ -2,16 +2,16 @@ import * as path from 'node:path'; import { fileURLToPath } from 'node:url'; import { SfCommand, Flags } from '@salesforce/sf-plugins-core'; import { Messages } from '@salesforce/core'; -import { generateTemplate1, initializeTemplate1 } from '../../utils/triggerFactory.js'; +import { generateTemplates } from '../../utils/triggerFactory.js'; Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); const messages = Messages.loadMessages('kc-sf-plugin', 'kc.trigger-framework'); -export type KcApexFactoryTriggerFrameworkResult = { +export type KcTriggerFrameworkResult = { createdFiles: string[]; }; -export default class KcApexFactoryTriggerFramework extends SfCommand { +export default class KcTriggerFramework extends SfCommand { public static readonly summary = messages.getMessage('summary'); public static readonly description = messages.getMessage('description'); public static readonly examples = messages.getMessages('examples'); @@ -26,51 +26,51 @@ export default class KcApexFactoryTriggerFramework extends SfCommand { - const { flags } = await this.parse(KcApexFactoryTriggerFramework); + public async run(): Promise { + const { flags } = await this.parse(KcTriggerFramework); const targetDir = flags['target-dir']; const init = flags['init']; const sobjects = flags['sobject']; const template = flags['template']; - let templateDir = flags['template-override']; let createdFiles: string[] = []; + const customTemplateDir = flags['custom-template']; const defaultTemplateDir = '../../templates/'; const filename = fileURLToPath(import.meta.url); const dirname = path.dirname(filename); + let templateDir: string; switch (template) { - case '1': - if (templateDir === undefined) { - templateDir = path.resolve(dirname, defaultTemplateDir.concat('template-1/')); - } - if (init) { - createdFiles = initializeTemplate1(targetDir, templateDir); - } else if (sobjects !== undefined) { - createdFiles = generateTemplate1(sobjects, targetDir, templateDir); + case undefined: + if (customTemplateDir !== undefined) { + createdFiles = generateTemplates(targetDir, customTemplateDir, init, sobjects); } break; + case '1': + templateDir = path.resolve(dirname, defaultTemplateDir.concat('template-1/')); + createdFiles = generateTemplates(targetDir, templateDir, init, sobjects); + break; default: break; diff --git a/src/templates/template-1/init.json b/src/templates/template-1/init.json new file mode 100644 index 0000000..9ce69ca --- /dev/null +++ b/src/templates/template-1/init.json @@ -0,0 +1,15 @@ +{ + "BypassCustomObject.txt": { + "type": "object", + "name": "BypassAutomation__c", + "init": true + }, + "TriggerHandlerVirtualClass.txt": { + "type": "class", + "name": "TriggerHandler" + }, + "TriggerHandlerVirtualClass_Test.txt": { + "type": "class", + "name": "TriggerHandler_Test" + } +} diff --git a/src/templates/template-1/sobject.json b/src/templates/template-1/sobject.json new file mode 100644 index 0000000..1f1d852 --- /dev/null +++ b/src/templates/template-1/sobject.json @@ -0,0 +1,23 @@ +{ + "BypassCustomField.txt": { + "type": "field", + "name": "{{sobject}}__c", + "object": "BypassAutomation__c" + }, + "SObjectTrigger.txt": { + "type": "trigger", + "name": "{{sobject}}Trigger" + }, + "SObjectTriggerHandler.txt": { + "type": "class", + "name": "{{sobject}}TriggerHandler" + }, + "SObjectTriggerHelper.txt": { + "type": "class", + "name": "{{sobject}}Helper" + }, + "SObjectTriggerHelper_Test.txt": { + "type": "class", + "name": "{{sobject}}Helper_Test" + } +} diff --git a/src/utils/triggerFactory.ts b/src/utils/triggerFactory.ts index de346af..915e26b 100644 --- a/src/utils/triggerFactory.ts +++ b/src/utils/triggerFactory.ts @@ -3,7 +3,7 @@ import * as path from 'node:path'; import { fileURLToPath } from 'node:url'; import { Messages } from '@salesforce/core'; import { ux } from '@oclif/core'; -import { ApexFileType, TemplateFiles, apiVersion } from './types.js'; +import { ApexFileType, JsonData, TemplateFiles, apiVersion } from './types.js'; const filename = fileURLToPath(import.meta.url); const dirname = path.dirname(filename); @@ -11,101 +11,72 @@ const sharedTemplates = path.resolve(dirname, '../templates/shared/'); Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); const apexFactoryMessages = Messages.loadMessages('kc-sf-plugin', 'apexFactory'); -export const initializeTemplate1 = (targetDir: string, templateDir: string): string[] => { +export const generateTemplate = (targetDir: string, templateDir: string, init: boolean, sobject?: string): string[] => { const createdFiles: string[] = []; const classesDir = targetDir.concat('/classes/'); + const triggersDir = targetDir.concat('/triggers/'); const customObjectDir = targetDir.concat('/objects/'); - const customSettingName = 'BypassAutomation__c'; - const triggerHandlerFileName = 'TriggerHandler.cls'; - createdFiles.push( - copyApexClass(TemplateFiles.TriggerHandlerVirtualClass, triggerHandlerFileName, classesDir, templateDir) - ); - - const triggerHandlerTestFileName = 'TriggerHandler_Test.cls'; - createdFiles.push( - copyApexClass(TemplateFiles.TriggerHandlerVirtualClassTest, triggerHandlerTestFileName, classesDir, templateDir) - ); - - createdFiles.push( - createCustomObject(TemplateFiles.BypassCustomObject, customSettingName, customObjectDir, templateDir) - ); - - return createdFiles; -}; - -export const generateTemplate1 = (sobjects: string[], targetDir: string, templateDir: string): string[] => { - const createdFiles: string[] = []; - const classesDir = targetDir.concat('/classes/'); - const triggerDir = targetDir.concat('/triggers/'); - const customObjectDir = targetDir.concat('/objects/'); - const customSettingName = 'BypassAutomation__c'; - - sobjects.forEach((sobject) => { - const tokens = new Map([['{{sobject}}', sobject]]); - - const triggerName = sobject.concat('Trigger.trigger'); - createdFiles.push( - createApexFile(TemplateFiles.SObjectTrigger, triggerName, triggerDir, 'trigger', tokens, templateDir) - ); - - const handlerName = sobject.concat('TriggerHandler.cls'); - createdFiles.push( - createApexFile(TemplateFiles.SObjectHandler, handlerName, classesDir, 'class', tokens, templateDir) - ); - - const helperName = sobject.concat('Helper.cls'); - createdFiles.push( - createApexFile(TemplateFiles.SObjectHelper, helperName, classesDir, 'class', tokens, templateDir) - ); - - const helperTestName = sobject.concat('Helper_Test.cls'); - createdFiles.push( - createApexFile(TemplateFiles.SObjectHelperTest, helperTestName, classesDir, 'class', tokens, templateDir) - ); - - const bypassFieldName = sobject.concat('__c.field-meta.xml'); - createdFiles.push( - createField( - TemplateFiles.BypassCustomField, - bypassFieldName, - customSettingName, - customObjectDir, - tokens, - templateDir - ) - ); - }); + let instructions: string; + const tokens = new Map(); + if (sobject !== undefined) { + tokens.set('{{sobject}}', sobject); + instructions = path.resolve(templateDir, 'sobject.json'); + } else { + instructions = path.resolve(templateDir, 'init.json'); + } + const data = fs.readFileSync(instructions, 'utf-8'); + const jsonData = JSON.parse(data) as JsonData; + + for (const [template, details] of Object.entries(jsonData)) { + let fileName = details.name; + for (const [key, val] of tokens) { + fileName = fileName.replaceAll(key, val); + } + + switch (details.type) { + case 'class': + createdFiles.push(createApexFile(template, fileName, classesDir, details.type, tokens, templateDir)); + break; + case 'trigger': + createdFiles.push(createApexFile(template, fileName, triggersDir, details.type, tokens, templateDir)); + break; + case 'object': + createdFiles.push(createCustomObject(template, fileName, customObjectDir, tokens, templateDir)); + break; + case 'field': + createdFiles.push(createField(template, fileName, details.object, customObjectDir, tokens, templateDir)); + break; + default: + break; + } + } - return createdFiles; + return ['']; }; -export const copyApexClass = ( - template: string, - outputFileName: string, +export const generateTemplates = ( targetDir: string, - templateDir: string -): string => { - const classTemplate = path.resolve(templateDir, template); - const classDefTemplate = path.resolve(sharedTemplates, TemplateFiles.ApexClassDefinition); - const classDefContent = fs.readFileSync(classDefTemplate, 'utf-8').replaceAll('{{apiVersion}}', apiVersion); + templateDir: string, + init: boolean, + sobjects?: string[] +): string[] => { + const createdFiles: string[] = []; - verifyDirectory(targetDir); - const outputDir = targetDir.concat(outputFileName); - if (!fs.existsSync(outputDir)) { - fs.copyFileSync(classTemplate, outputDir); - fs.writeFileSync(outputDir.concat('-meta.xml'), classDefContent); - ux.log(apexFactoryMessages.getMessage('file.created', [outputDir])); - return outputFileName; - } else { - ux.log(apexFactoryMessages.getMessage('file.exists', [outputDir])); + if (sobjects !== undefined) { + sobjects.forEach((sobject) => { + createdFiles.push(...generateTemplate(targetDir, templateDir, init, sobject)); + }); + } else if (init) { + createdFiles.push(...generateTemplate(targetDir, templateDir, init)); } - return ''; + + return createdFiles; }; export const createApexFile = ( template: string, - outputFileName: string, + name: string, targetDir: string, type: ApexFileType, tokens: Map, @@ -113,11 +84,14 @@ export const createApexFile = ( ): string => { const apexTemplate = path.resolve(templateDir, template); let apexDefTemplate: string; + let outputFileName: string; if (type === 'class') { apexDefTemplate = path.resolve(sharedTemplates, TemplateFiles.ApexClassDefinition); + outputFileName = name.concat('.cls'); } else { apexDefTemplate = path.resolve(sharedTemplates, TemplateFiles.ApexTriggerDefinition); + outputFileName = name.concat('.trigger'); } const apexDefContent = fs.readFileSync(apexDefTemplate, 'utf-8').replaceAll('{{apiVersion}}', apiVersion); let apexTemplateContent = fs.readFileSync(apexTemplate, 'utf-8'); @@ -142,11 +116,15 @@ export const createCustomObject = ( template: string, objectName: string, targetDir: string, + tokens: Map, templateDir: string ): string => { - const objectTemplate = path.resolve(templateDir, template); - const objectTemplateContent = fs.readFileSync(objectTemplate, 'utf-8'); const outputFileName = objectName.concat('.object-meta.xml'); + const objectTemplate = path.resolve(templateDir, template); + let objectTemplateContent = fs.readFileSync(objectTemplate, 'utf-8'); + for (const [key, val] of tokens) { + objectTemplateContent = objectTemplateContent.replaceAll(key, val); + } let outputDir = targetDir.concat(objectName); verifyDirectory(outputDir); @@ -163,12 +141,13 @@ export const createCustomObject = ( export const createField = ( template: string, - outputFileName: string, + fieldName: string, object: string, targetDir: string, tokens: Map, templateDir: string ): string => { + const outputFileName = fieldName.concat('.field-meta.xml'); const fieldTemplate = path.resolve(templateDir, template); let fieldTemplateContent = fs.readFileSync(fieldTemplate, 'utf-8'); for (const [key, val] of tokens) { diff --git a/src/utils/types.ts b/src/utils/types.ts index 46ec6b7..6aab4b4 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -35,6 +35,16 @@ export type ApexFileType = 'class' | 'trigger'; export const apiVersion: string = '60.0'; +export type JsonData = { + [key: string]: FileInfo; +}; + +export type FileInfo = { + type: 'class' | 'trigger' | 'object' | 'field'; + name: string; + object: string; +}; + /** validates source component with fullname, type, and xml props */ export const isSourceComponent = (sc: ComponentLike): sc is SourceComponent => isObject(sc) && diff --git a/test/commands/kc/trigger-framework.nut.ts b/test/commands/kc/trigger-framework.nut.ts index 83747c1..11a27de 100644 --- a/test/commands/kc/trigger-framework.nut.ts +++ b/test/commands/kc/trigger-framework.nut.ts @@ -2,7 +2,7 @@ import path from 'node:path'; import { TestSession, execCmd } from '@salesforce/cli-plugins-testkit'; import assert from 'yeoman-assert'; -describe('kc apex-factory trigger-framework trigger', () => { +describe('kc apex-factory trigger-framework trigger network tests', () => { let session: TestSession; before(async () => { @@ -58,4 +58,37 @@ describe('kc apex-factory trigger-framework trigger', () => { ) ); }); + + it('runs kc apex-factory trigger-framework with 2 sobjects', async () => { + execCmd('kc:trigger-framework --template 1 --sobject Lead --sobject Contact'); + assert.file( + [ + 'LeadTrigger.trigger', + 'LeadTrigger.trigger-meta.xml', + 'ContactTrigger.trigger', + 'ContactTrigger.trigger-meta.xml', + ].map((f) => path.join(session.project.dir.concat('/force-app/main/default/triggers'), f)) + ); + assert.file( + [ + 'LeadTriggerHandler.cls', + 'LeadTriggerHandler.cls-meta.xml', + 'LeadHelper.cls', + 'LeadHelper.cls-meta.xml', + 'LeadHelper_Test.cls', + 'LeadHelper_Test.cls-meta.xml', + 'ContactTriggerHandler.cls', + 'ContactTriggerHandler.cls-meta.xml', + 'ContactHelper.cls', + 'ContactHelper.cls-meta.xml', + 'ContactHelper_Test.cls', + 'ContactHelper_Test.cls-meta.xml', + ].map((f) => path.join(session.project.dir.concat('/force-app/main/default/classes'), f)) + ); + assert.file( + ['Lead__c.field-meta.xml', 'Contact__c.field-meta.xml'].map((f) => + path.join(session.project.dir.concat('/force-app/main/default/objects/BypassAutomation__c/fields'), f) + ) + ); + }); }); diff --git a/test/commands/kc/trigger-framework.test.ts b/test/commands/kc/trigger-framework.test.ts new file mode 100644 index 0000000..2d371f0 --- /dev/null +++ b/test/commands/kc/trigger-framework.test.ts @@ -0,0 +1,33 @@ +import { expect } from 'chai'; +import KcTriggerFramework from '../../../src/commands/kc/trigger-framework.js'; + +describe('kc apex-factory trigger-framework trigger unit tests', () => { + it('throws an error when neither --sobject or --init flags are used', async () => { + try { + const response = await KcTriggerFramework.run(['--template', '1']); + expect.fail(`Should throw an error. Response: ${JSON.stringify(response)}`); + } catch (e) { + expect((e as Error).message).to.include('Exactly one of the following must be provided: --init, --sobject'); + } + }); + + it('throws an error when the --sobject and --init flags are both given', async () => { + try { + const response = await KcTriggerFramework.run(['--template', '1', '--init', '--sobject', 'Account']); + expect.fail(`Should throw an error. Response: ${JSON.stringify(response)}`); + } catch (e) { + expect((e as Error).message).to.include('--init cannot also be provided when using --sobject'); + expect((e as Error).message).to.include('--sobject cannot also be provided when using --init'); + } + }); + + it('throws an error when --template and --custom-template flags are both given', async () => { + try { + const response = await KcTriggerFramework.run(['--template', '1', '--custom-template', '/', '--init']); + expect.fail(`Should throw an error. Response: ${JSON.stringify(response)}`); + } catch (e) { + expect((e as Error).message).to.include('--custom-template cannot also be provided when using --template'); + expect((e as Error).message).to.include('--template cannot also be provided when using --custom-template'); + } + }); +}); diff --git a/test/utils/triggerFactory.nut.ts b/test/utils/triggerFactory.nut.ts index 93e197b..c9fcc95 100644 --- a/test/utils/triggerFactory.nut.ts +++ b/test/utils/triggerFactory.nut.ts @@ -4,7 +4,7 @@ import { expect } from 'chai'; import { TestSession } from '@salesforce/cli-plugins-testkit'; import assert from 'yeoman-assert'; import { TemplateFiles } from '../../src/utils/types.js'; -import { copyApexClass, createApexFile, createCustomObject, createField } from '../../src/utils/triggerFactory.js'; +import { createApexFile, createCustomObject, createField } from '../../src/utils/triggerFactory.js'; describe('kc apex-factory trigger-framework trigger', () => { let session: TestSession; @@ -23,32 +23,12 @@ describe('kc apex-factory trigger-framework trigger', () => { await session?.clean(); }); - it('copies apex file to a path', async () => { - const result = copyApexClass( - TemplateFiles.TriggerHandlerVirtualClass, - 'TriggerHandler.cls', - session.project.dir, - template1Dir - ); - expect(result).to.equal('TriggerHandler.cls'); - }); - - it('does not copy apex file to a path because it already exists', async () => { - const result = copyApexClass( - TemplateFiles.TriggerHandlerVirtualClass, - 'TriggerHandler.cls', - session.project.dir, - template1Dir - ); - expect(result).to.equal(''); - }); - it('creates apex trigger to a path and replaces tokens', async () => { const triggerDir = session.project.dir.concat('/force-app/main/default/triggers/'); const tokens = new Map([['{{sobject}}', 'Account']]); const result = createApexFile( TemplateFiles.SObjectTrigger, - 'AccountTrigger.trigger', + 'AccountTrigger', triggerDir, 'trigger', tokens, @@ -62,7 +42,7 @@ describe('kc apex-factory trigger-framework trigger', () => { const triggerDir = session.project.dir.concat('/force-app/main/default/triggers/'); const result = createApexFile( TemplateFiles.SObjectTrigger, - 'AccountTrigger.trigger', + 'AccountTrigger', triggerDir, 'trigger', new Map(), @@ -76,7 +56,7 @@ describe('kc apex-factory trigger-framework trigger', () => { const tokens = new Map([['{{sobject}}', 'Account']]); const result = createApexFile( TemplateFiles.SObjectHandler, - 'AccountTriggerHandler.cls', + 'AccountTriggerHandler', classesDir, 'class', tokens, @@ -94,17 +74,17 @@ describe('kc apex-factory trigger-framework trigger', () => { const tokens = new Map([['{{sobject}}', 'Account']]); const result = createField( TemplateFiles.BypassCustomField, - 'Account.field-meta.xml', + 'Account__c', 'BypassAutomation__c', objectsDir, tokens, template1Dir ); - expect(result).to.equal('Account.field-meta.xml'); - assert.file(path.join(objectsDir.concat('/BypassAutomation__c/fields/Account.field-meta.xml'))); + expect(result).to.equal('Account__c.field-meta.xml'); + assert.file(path.join(objectsDir.concat('/BypassAutomation__c/fields/Account__c.field-meta.xml'))); assert.fileContent( - path.join(objectsDir.concat('/BypassAutomation__c/fields/', 'Account.field-meta.xml')), - 'Account' + path.join(objectsDir.concat('/BypassAutomation__c/fields/', 'Account__c.field-meta.xml')), + 'Account__c' ); }); @@ -113,7 +93,7 @@ describe('kc apex-factory trigger-framework trigger', () => { const tokens = new Map([['{{sobject}}', 'Account']]); const result = createField( TemplateFiles.BypassCustomField, - 'Account.field-meta.xml', + 'Account__c', 'BypassAutomation__c', objectsDir, tokens, @@ -128,6 +108,7 @@ describe('kc apex-factory trigger-framework trigger', () => { TemplateFiles.BypassCustomObject, 'BypassAutomation__c', objectsDir, + new Map(), template1Dir ); expect(result).to.equal('BypassAutomation__c.object-meta.xml'); @@ -140,6 +121,7 @@ describe('kc apex-factory trigger-framework trigger', () => { TemplateFiles.BypassCustomObject, 'BypassAutomation__c', objectsDir, + new Map(), template1Dir ); expect(result).to.equal('');