From 8ac5518a802781d24f6d89482050a7e4ad223b19 Mon Sep 17 00:00:00 2001 From: Sebastien Date: Wed, 17 Apr 2024 09:37:02 +0200 Subject: [PATCH] fix: type detection of `EmailServicesFunction` metadata type (#831) --- .github/linters/.cspell.json | 69 ++++++++++--------- .../metadata/MetadataRepositoryImpl.test.ts | 25 +++++++ src/constant/metadataConstants.ts | 1 + src/metadata/MetadataRepositoryImpl.ts | 2 + 4 files changed, 63 insertions(+), 34 deletions(-) diff --git a/.github/linters/.cspell.json b/.github/linters/.cspell.json index 3e408e4e..2a34dfa6 100644 --- a/.github/linters/.cspell.json +++ b/.github/linters/.cspell.json @@ -1,46 +1,20 @@ { "ignorePaths": [ "**/CHANGELOG.md", - "**/node_modules/**", "**/.git/**", - "**/megalinter.yml", - "**/yarn.lock", "**/.yarnrc.yml", + "**/megalinter.yml", + "**/node_modules/**", "**/src/metadata/**", - "**/src/service/typeHandlerFactory.ts" + "**/src/service/typeHandlerFactory.ts", + "**/yarn.lock" ], "language": "en", "noConfigSearch": true, "version": "0.2", "words": [ + "\u00c0gain", "Afile", - "CODECOV", - "CODEOWNERS", - "Cherfaoui", - "Colladon", - "Commitlint", - "depcheckrc", - "FORCEIGNORE", - "FORCEINCLUDE", - "FULLNAME", - "Flexi", - "gitdir", - "hardlinks", - "Iframe", - "knip", - "METAFILE", - "Mehdi", - "Nimn", - "Omni", - "Parens", - "SFDX", - "STATICRESOURCE", - "Scontrol", - "Sebastien", - "Sfdx", - "Translationline", - "Unpackaged", - "Wavehandler", "amannn", "anotherignore", "apexskier", @@ -51,34 +25,49 @@ "behaviour", "benchmarkjs", "brqh", + "Cherfaoui", "codeclimate", "codecov", + "CODECOV", + "CODEOWNERS", + "Colladon", "commandsstop", "commitlint", + "Commitlint", "contentassets", "customindex", "datacategorygroup", "datacategorygroups", + "depcheck", + "depcheckrc", "destructiveignore", "destructiveinclude", - "depcheck", "emailservices", + "EMAILSERVICESFUNCTION", "eslintcache", "firstsha", + "Flexi", "flexipage", "flexipages", "flowtest", "flowtests", "flowtype", "forceignore", + "FORCEIGNORE", "forceinclude", + "FORCEINCLUDE", "friendlyname", + "FULLNAME", "geodata", + "gitdir", + "hardlinks", "iframe", + "Iframe", "ignorewarnings", "iife", "indx", "Infile", + "knip", "lcov", "linebreak", "lintstagedrc", @@ -86,8 +75,10 @@ "lwcc", "mdapi", "megalinter", + "Mehdi", "mehdisfdc", "metafile", + "METAFILE", "mjyhjbm", "mkdirs", "mocharc", @@ -96,6 +87,7 @@ "mutingpermissionset", "mutingpermissionsets", "myexperiencebundle", + "Nimn", "nonblock", "notblank", "notexist", @@ -107,8 +99,10 @@ "oauthcustomscopes", "oclif", "omni", + "Omni", "omnistudio", "oxsecurity", + "Parens", "pastsha", "permissionset", "permissionsetgroup", @@ -127,12 +121,17 @@ "samlssoconfig", "samlssoconfigs", "scolladon", + "Scontrol", "scontrols", + "Sebastien", "sfdx", + "Sfdx", + "SFDX", "sgdignore", "sgdinclude", "sgdincludedestructive", "shellcheck", + "STATICRESOURCE", "staticresources", "stefanzweifel", "struc", @@ -141,14 +140,17 @@ "testkit", "testlevel", "testtest", + "Translationline", "trivyignore", "tsbuildinfo", "unmanaged", "unmocked", "unpackaged", + "Unpackaged", "venv", "wagoid", "wapp", + "Wavehandler", "wcomp", "wdash", "wdpr", @@ -158,7 +160,6 @@ "wireit", "wlens", "xmlbuilder", - "yarnrc", - "\u00c0gain" + "yarnrc" ] } \ No newline at end of file diff --git a/__tests__/unit/lib/metadata/MetadataRepositoryImpl.test.ts b/__tests__/unit/lib/metadata/MetadataRepositoryImpl.test.ts index 431abcae..9b25833f 100644 --- a/__tests__/unit/lib/metadata/MetadataRepositoryImpl.test.ts +++ b/__tests__/unit/lib/metadata/MetadataRepositoryImpl.test.ts @@ -97,6 +97,13 @@ describe('MetadataRepositoryImpl', () => { suffix: 'resource', xmlName: 'StaticResource', }, + { + directoryName: 'emailservices', + inFolder: false, + metaFile: false, + suffix: 'xml', + xmlName: 'EmailServicesFunction', + }, ]) }) describe('has', () => { @@ -198,6 +205,16 @@ describe('MetadataRepositoryImpl', () => { expect.objectContaining({ directoryName: 'moderation' }) ) }) + + it('matches `xml` files inside `emailservices` folder', () => { + // Act + const result = sut.get('force-app/emailservices/testService.xml') + + // Assert + expect(result).toStrictEqual( + expect.objectContaining({ directoryName: 'emailservices' }) + ) + }) }) describe('when matching on extension', () => { @@ -267,6 +284,14 @@ describe('MetadataRepositoryImpl', () => { }) describe('when it should not match on extension', () => { + it('does not match `xml` files outside `emailservices` folder', () => { + // Act + const result = sut.get('manifest/specificTestClasses.xml') + + // Assert + expect(result).toBeUndefined() + }) + it('matches on folder', () => { // Act const result = sut.get( diff --git a/src/constant/metadataConstants.ts b/src/constant/metadataConstants.ts index 226a7b1f..86298d3b 100644 --- a/src/constant/metadataConstants.ts +++ b/src/constant/metadataConstants.ts @@ -1,6 +1,7 @@ 'use strict' export const CUSTOM_APPLICATION_TYPE = 'applications' +export const EMAILSERVICESFUNCTION_SUFFIX = 'emailservices' export const FIELD_DIRECTORY_NAME = 'fields' export const FLOW_XML_NAME = 'Flow' export const INFOLDER_SUFFIX = `Folder` diff --git a/src/metadata/MetadataRepositoryImpl.ts b/src/metadata/MetadataRepositoryImpl.ts index f56da257..e6a0108d 100644 --- a/src/metadata/MetadataRepositoryImpl.ts +++ b/src/metadata/MetadataRepositoryImpl.ts @@ -5,6 +5,7 @@ import { parse } from 'path' import { DOT, PATH_SEP } from '../constant/fsConstants' import { CUSTOM_APPLICATION_TYPE, + EMAILSERVICESFUNCTION_SUFFIX, METAFILE_SUFFIX, OBJECT_TRANSLATION_TYPE, OBJECT_TYPE, @@ -101,6 +102,7 @@ export class MetadataRepositoryImpl implements MetadataRepository { private static EXTENSION_MATCHING_EXCEPTION = [ CUSTOM_APPLICATION_TYPE, RESTRICTION_RULE_TYPE, + EMAILSERVICESFUNCTION_SUFFIX, ] private static COMPOSED_TYPES = [