Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: metadata type detection on file extension #835

Merged
merged 3 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 28 additions & 26 deletions .github/linters/.cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": "0.2",
"words": [
"\u00c0gain",
"Afile",
"afile",
"amannn",
"anotherignore",
"apexskier",
Expand All @@ -25,15 +25,15 @@
"behaviour",
"benchmarkjs",
"brqh",
"Cherfaoui",
"cherfaoui",
"codeclimate",
"codecov",
"CODECOV",
"CODEOWNERS",
"Colladon",
"codecov",
"codeowners",
"colladon",
"commandsstop",
"commitlint",
"Commitlint",
"commitlint",
"contentassets",
"customindex",
"datacategorygroup",
Expand All @@ -43,30 +43,31 @@
"destructiveignore",
"destructiveinclude",
"emailservices",
"EMAILSERVICESFUNCTION",
"emailservicesfunction",
"eslintcache",
"experiencebundle",
"firstsha",
"Flexi",
"flexi",
"flexipage",
"flexipages",
"flowtest",
"flowtests",
"flowtype",
"forceignore",
"FORCEIGNORE",
"forceignore",
"forceinclude",
"forceinclude",
"FORCEINCLUDE",
"friendlyname",
"FULLNAME",
"fullname",
"geodata",
"gitdir",
"hardlinks",
"iframe",
"Iframe",
"iframe",
"ignorewarnings",
"iife",
"indx",
"Infile",
"infile",
"knip",
"lcov",
"linebreak",
Expand All @@ -75,10 +76,10 @@
"lwcc",
"mdapi",
"megalinter",
"Mehdi",
"mehdi",
"mehdisfdc",
"metafile",
"METAFILE",
"metafile",
"mjyhjbm",
"mkdirs",
"mocharc",
Expand All @@ -87,7 +88,7 @@
"mutingpermissionset",
"mutingpermissionsets",
"myexperiencebundle",
"Nimn",
"nimn",
"nonblock",
"notblank",
"notexist",
Expand All @@ -99,10 +100,10 @@
"oauthcustomscopes",
"oclif",
"omni",
"Omni",
"omni",
"omnistudio",
"oxsecurity",
"Parens",
"parens",
"pastsha",
"permissionset",
"permissionsetgroup",
Expand All @@ -121,17 +122,18 @@
"samlssoconfig",
"samlssoconfigs",
"scolladon",
"Scontrol",
"scontrol",
"scontrols",
"Sebastien",
"sebastien",
"sfdx",
"sfdx",
"sfdx",
"Sfdx",
"SFDX",
"sgdignore",
"sgdinclude",
"sgdincludedestructive",
"shellcheck",
"STATICRESOURCE",
"sitedotcom",
"staticresource",
"staticresources",
"stefanzweifel",
"struc",
Expand All @@ -140,17 +142,17 @@
"testkit",
"testlevel",
"testtest",
"Translationline",
"translationline",
"trivyignore",
"tsbuildinfo",
"unmanaged",
"unmocked",
"unpackaged",
"Unpackaged",
"unpackaged",
"venv",
"wagoid",
"wapp",
"Wavehandler",
"wavehandler",
"wcomp",
"wdash",
"wdpr",
Expand Down
70 changes: 62 additions & 8 deletions __tests__/unit/lib/metadata/MetadataRepositoryImpl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,27 @@ describe('MetadataRepositoryImpl', () => {
suffix: 'xml',
xmlName: 'EmailServicesFunction',
},
{
directoryName: 'sites',
inFolder: false,
metaFile: false,
suffix: 'site',
xmlName: 'CustomSite',
},
{
directoryName: 'siteDotComSites',
inFolder: false,
metaFile: true,
suffix: 'site',
xmlName: 'SiteDotCom',
},
{
directoryName: 'experiences',
inFolder: false,
metaFile: true,
suffix: 'site',
xmlName: 'ExperienceBundle',
},
])
})
describe('has', () => {
Expand Down Expand Up @@ -206,14 +227,47 @@ describe('MetadataRepositoryImpl', () => {
)
})

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('special cases where it should only match on folder', () => {
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' })
)
})
it('should match `Site`', () => {
// Act
const result = sut.get('Z force-app/main/default/sites/aSite.site')

// Assert
expect(result).toStrictEqual(
expect.objectContaining({ directoryName: 'sites' })
)
})
it('should match `SiteDotCom`', () => {
// Act
const result = sut.get(
'Z force-app/main/default/siteDotComSites/aSitedotcom.site'
)

// Assert
expect(result).toStrictEqual(
expect.objectContaining({ directoryName: 'siteDotComSites' })
)
})
it('should match `ExperienceBundle`', () => {
// Act
const result = sut.get(
'Z force-app/main/default/experiences/aCommunity.site'
)

// Assert
expect(result).toStrictEqual(
expect.objectContaining({ directoryName: 'experiences' })
)
})
})
})

Expand Down
3 changes: 3 additions & 0 deletions src/constant/metadataConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

export const CUSTOM_APPLICATION_TYPE = 'applications'
export const EMAILSERVICESFUNCTION_SUFFIX = 'emailservices'
export const EXPERIENCEBUNDLE_FOLDER = 'experiences'
export const FIELD_DIRECTORY_NAME = 'fields'
export const FLOW_XML_NAME = 'Flow'
export const INFOLDER_SUFFIX = `Folder`
Expand All @@ -16,6 +17,8 @@ export const OBJECT_TRANSLATION_META_XML_SUFFIX = `objectTranslation${METAFILE_S
export const OBJECT_TYPE = 'objects'
export const OBJECT_XML_NAME = 'CustomObject'
export const RESTRICTION_RULE_TYPE = 'restrictionRules'
export const SITE_FOLDER = 'sites'
export const SITEDOTCOM_FOLDER = 'siteDotComSites'
export const SUB_OBJECT_TYPES = [
'businessProcesses',
'compactLayouts',
Expand Down
6 changes: 6 additions & 0 deletions src/metadata/MetadataRepositoryImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ import { DOT, PATH_SEP } from '../constant/fsConstants'
import {
CUSTOM_APPLICATION_TYPE,
EMAILSERVICESFUNCTION_SUFFIX,
EXPERIENCEBUNDLE_FOLDER,
METAFILE_SUFFIX,
OBJECT_TRANSLATION_TYPE,
OBJECT_TYPE,
RESTRICTION_RULE_TYPE,
SITEDOTCOM_FOLDER,
SITE_FOLDER,
SUB_OBJECT_TYPES,
TERRITORY_MODEL_TYPE,
} from '../constant/metadataConstants'
Expand Down Expand Up @@ -103,6 +106,9 @@ export class MetadataRepositoryImpl implements MetadataRepository {
CUSTOM_APPLICATION_TYPE,
RESTRICTION_RULE_TYPE,
EMAILSERVICESFUNCTION_SUFFIX,
SITE_FOLDER,
SITEDOTCOM_FOLDER,
EXPERIENCEBUNDLE_FOLDER,
]

private static COMPOSED_TYPES = [
Expand Down
Loading