UNPKG

salesforce-alm

Version:

This package contains tools, and APIs, for an improved salesforce.com developer experience.

61 lines (59 loc) 2.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.toArray = exports.parseToManifestEntriesArray = void 0; /* * 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 */ const core_1 = require("@salesforce/core"); const mdapiRetrieveApi_1 = require("../mdapi/mdapiRetrieveApi"); const PathUtil = require("../source/sourcePathUtil"); /** * Parse the manifest file and create a list ManifestEntry objects. * * @param manifestPath {string} The filepath for the manifest * @returns {ManifestEntry[]} An array for ManifestEntry objects from the manifest. */ exports.parseToManifestEntriesArray = async function (manifestPath) { const entries = []; const options = { unpackaged: manifestPath, }; return mdapiRetrieveApi_1.MdRetrieveApi._getPackageJson(undefined, options).then((manifestJson) => { exports.toArray(manifestJson.types).forEach((type) => { if (!type.name) { const errConfig = new core_1.SfdxErrorConfig('salesforce-alm', 'source', 'IllFormattedManifest'); errConfig.setErrorTokens(['; <name> is missing']); throw core_1.SfdxError.create(errConfig); } exports.toArray(type.members).forEach((member) => { const _member = PathUtil.replaceForwardSlashes(member); entries.push({ type: type.name, name: _member, }); }); }); return entries; }); }; /** * Convert the argument into an array datatype * * @param arrayOrObjectOrUndefined * @returns Array */ exports.toArray = function (arrayOrObjectOrUndefined) { if (!arrayOrObjectOrUndefined) { return []; } else if (Array.isArray(arrayOrObjectOrUndefined)) { return arrayOrObjectOrUndefined; } else { return [arrayOrObjectOrUndefined]; } }; //# sourceMappingURL=parseManifestEntriesArray.js.map