sf-decomposer
Version:
Break down large Salesforce metadata files into smaller, more manageable files for version control and then recreate deployment-compatible files.
38 lines • 2.09 kB
JavaScript
;
import { RegistryAccess } from '@salesforce/source-deploy-retrieve';
import { DEFAULT_UNIQUE_ID_ELEMENTS } from '../helpers/constants.js';
import { getUniqueIdElements } from './getUniqueIdElements.js';
import { getPackageDirectories } from './getPackageDirectories.js';
export async function getRegistryValuesBySuffix(metaSuffix, command, ignoreDirs) {
if (metaSuffix === 'object') {
throw Error('Custom Objects are not supported by this plugin.');
}
if (metaSuffix === 'botVersion') {
throw Error('`botVersion` suffix should not be used. Please use `bot` to decompose/recompose bot and bot version files.');
}
const registryAccess = new RegistryAccess();
const metadataTypeEntry = registryAccess.getTypeBySuffix(metaSuffix);
if (metadataTypeEntry === undefined)
throw Error(`Metadata type not found for the given suffix: ${metaSuffix}.`);
if (metadataTypeEntry.strategies?.adapter &&
['matchingContentFile', 'digitalExperience', 'mixedContent', 'bundle'].includes(metadataTypeEntry.strategies.adapter)) {
throw Error(`Metadata types with ${metadataTypeEntry.strategies.adapter} strategies are not supported by this plugin.`);
}
let uniqueIdElements;
if (command === 'decompose')
uniqueIdElements = await getUniqueIdElements(metaSuffix);
const { metadataPaths, ignorePath } = await getPackageDirectories(`${metadataTypeEntry.directoryName}`, ignoreDirs);
if (metadataPaths.length === 0)
throw Error(`No directories named ${metadataTypeEntry.directoryName} were found in any package directory.`);
const metaAttributes = {
metaSuffix: metadataTypeEntry.suffix,
strictDirectoryName: metadataTypeEntry.strictDirectoryName,
folderType: metadataTypeEntry.folderType,
metadataPaths,
uniqueIdElements: uniqueIdElements
? `${DEFAULT_UNIQUE_ID_ELEMENTS},${uniqueIdElements}`
: DEFAULT_UNIQUE_ID_ELEMENTS,
};
return { metaAttributes, ignorePath };
}
//# sourceMappingURL=getRegistryValuesBySuffix.js.map