@salesforce/source-deploy-retrieve
Version:
JavaScript library to run Salesforce metadata deploys and retrieves
49 lines • 2.12 kB
JavaScript
/*
* Copyright (c) 2020, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.customLabelHasFullName = exports.parser = void 0;
exports.generateMetaXML = generateMetaXML;
exports.generateMetaXMLPath = generateMetaXMLPath;
exports.trimMetaXmlSuffix = trimMetaXmlSuffix;
const core_1 = require("@salesforce/core");
const fast_xml_parser_1 = require("fast-xml-parser");
const constants_1 = require("../common/constants");
exports.parser = new fast_xml_parser_1.XMLParser({
// include tag attributes and don't parse text node as number
ignoreAttributes: false,
parseTagValue: false,
parseAttributeValue: false,
cdataPropName: '__cdata',
ignoreDeclaration: true,
numberParseOptions: { leadingZeros: false, hex: false },
commentPropName: constants_1.XML_COMMENT_PROP_NAME,
});
function generateMetaXML(typeName, apiVersion, status) {
let templateResult = '<?xml version="1.0" encoding="UTF-8"?>\n';
templateResult += `<${typeName} xmlns="http://soap.sforce.com/2006/04/metadata">\n`;
templateResult += `\t<apiVersion>${apiVersion}.0</apiVersion>\n`;
if (status) {
templateResult += `\t<status>${status}</status>\n`;
}
templateResult += `</${typeName}>`;
return templateResult;
}
function generateMetaXMLPath(sourcePath) {
return sourcePath.endsWith(constants_1.META_XML_SUFFIX) ? sourcePath : `${sourcePath}${constants_1.META_XML_SUFFIX}`;
}
function trimMetaXmlSuffix(sourcePath) {
return sourcePath.endsWith(constants_1.META_XML_SUFFIX) ? sourcePath.replace(constants_1.META_XML_SUFFIX, '') : sourcePath;
}
const customLabelHasFullName = (label) => {
if (label.fullName === undefined) {
throw core_1.SfError.create({ message: 'Label does not have a fullName', data: label });
}
return true;
};
exports.customLabelHasFullName = customLabelHasFullName;
//# sourceMappingURL=metadata.js.map
;