UNPKG

@salesforce/source-deploy-retrieve

Version:

JavaScript library to run Salesforce metadata deploys and retrieves

64 lines 2.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PartialDecomposedAdapter = void 0; /* * Copyright (c) 2022, 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 */ const node_path_1 = require("node:path"); const sourceComponent_1 = require("../sourceComponent"); const utils_1 = require("../../utils"); const defaultSourceAdapter_1 = require("./defaultSourceAdapter"); /** * Handles types with partially decomposed content. This means that there will be 2+ files, * one being the parent (-meta.xml) and more being the "children" - these children make up one XML tag of the parent * * __Example Types__: * * DecomposeExternalServiceRegistrationBeta Preset * * __Example Structures__: * *```text * externalServiceRegistration/ * ├── myFoo.externalServiceRegistration-meta.xml * ├── myFoo.yaml * ├── myFoo.json *``` */ class PartialDecomposedAdapter extends defaultSourceAdapter_1.DefaultSourceAdapter { // eslint-disable-next-line @typescript-eslint/no-unused-vars populate(trigger, component) { const parentType = this.registry.getParentType(this.type.id); // no children of this type, // the parent has child types // and the trigger starts with one of the parent's child's suffixes // => we have a child path if (!this.type.children && parentType?.children && Object.keys(parentType.children.suffixes).find((suffix) => trigger.endsWith(`.${suffix}`))) { // we have a child, return the parent for the transformer to rebundle together return new sourceComponent_1.SourceComponent({ name: getName(trigger), type: parentType, // change the xml to point to the parent, the transformer will reassemble all parts to form valid MD format files xml: trigger.replace((0, utils_1.extName)(trigger), 'externalServiceRegistration-meta.xml'), }, this.tree, this.forceIgnore); } else { // we were given a parent return new sourceComponent_1.SourceComponent({ name: getName(trigger), type: this.type, xml: trigger, }, this.tree, this.forceIgnore); } } } exports.PartialDecomposedAdapter = PartialDecomposedAdapter; function getName(contentPath) { return (0, node_path_1.basename)(contentPath).split('.').at(0); } //# sourceMappingURL=partialDecomposedAdapter.js.map