UNPKG

salesforce-alm

Version:

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

90 lines (88 loc) 4.48 kB
"use strict"; /* * 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 */ /* eslint-disable @typescript-eslint/no-unused-vars */ Object.defineProperty(exports, "__esModule", { value: true }); exports.BundleMetadataType = void 0; const path = require("path"); const PathUtil = require("../sourcePathUtil"); const bundlePathHelper_1 = require("../bundlePathHelper"); const defaultMetadataType_1 = require("./defaultMetadataType"); class BundleMetadataType extends defaultMetadataType_1.DefaultMetadataType { constructor(typeDefObj) { super(typeDefObj); } getFullNameFromFilePath(filePath) { return bundlePathHelper_1.BundlePathHelper.buildFullNameFromFilePath(filePath, this.typeDefObj.defaultDirectory); } getAggregateFullNameFromFilePath(filePath) { return bundlePathHelper_1.BundlePathHelper.scanFilePathForAggregateFullName(filePath, this.typeDefObj.defaultDirectory); } getAggregateFullNameFromMdapiPackagePath(mdapiPackagePath) { return PathUtil.getParentDirectoryName(mdapiPackagePath); } getAggregateMetadataFilePathFromWorkspacePath(filePath) { return bundlePathHelper_1.BundlePathHelper.findMetadataFilePathInBundleDir(filePath, this.typeDefObj.defaultDirectory); } getDefaultAggregateMetadataPath(fullName, defaultSourceDir, bundleFileProperties) { return bundlePathHelper_1.BundlePathHelper.getPathFromBundleTypeFileProperties(fullName, defaultSourceDir, this.typeDefObj.defaultDirectory, bundleFileProperties); } getAggregateFullNameFromSourceMemberName(sourceMemberName) { return sourceMemberName.split(path.sep)[0]; } getAggregateFullNameFromWorkspaceFullName(workspaceFullName) { return workspaceFullName.split(path.sep)[0]; } getAggregateFullNameFromFileProperty(fileProperty, namespace) { return fileProperty.fullName.split(path.sep)[0]; } getPathToMdapiSourceDir(aggregateFullName, mdDir) { return path.join(mdDir, this.typeDefObj.defaultDirectory, aggregateFullName); } getOriginContentPathsForSourceConvert(metadataFilePath, workspaceVersion, unsupportedMimeTypes, forceIgnore) { const bundleDirPath = path.dirname(metadataFilePath); return Promise.resolve(bundlePathHelper_1.BundlePathHelper.getAllNestedBundleContentPaths(bundleDirPath, forceIgnore)); } // E.g. for a bundle with fullname=testbundle and an error in the helper the MD API response will contain: // "fileName": "metadataPackage_1497651865666/aura/testbundle/testbundleHelper.jss", // "fullName": "testbundle", getAggregateFullNameFromComponentFailure(componentFailure) { return this.getAggregateFullNameFromFilePath(componentFailure.fileName); } getWorkspaceFullNameFromComponentFailure(componentFailure) { return this.getFullNameFromFilePath(componentFailure.fileName); } handleSlashesForSourceMemberName(sourceMemberFullName) { return PathUtil.replaceForwardSlashes(sourceMemberFullName); } sourceMemberFullNameCorrespondsWithWorkspaceFullName(sourceMemberFullName, workspaceFullName) { return sourceMemberFullName === workspaceFullName; } isDefinitionFile(filePath, metadataRegistry) { // default implementation just returns false return false; } static getDefinitionProperties(fileProperties, metadataRegistry) { const clonedProps = JSON.parse(JSON.stringify(fileProperties)); const { MetadataTypeFactory } = require('../metadataTypeFactory'); return clonedProps .filter((fileProperty) => { const metadataType = MetadataTypeFactory.getMetadataTypeFromMetadataName(fileProperty.type, metadataRegistry); if (metadataType instanceof BundleMetadataType) { return metadataType.isDefinitionFile(fileProperty.fileName, metadataRegistry); } return false; }) .map((fileProperty) => { fileProperty.fullName = PathUtil.replaceForwardSlashes(fileProperty.fullName); fileProperty.fileName = PathUtil.replaceForwardSlashes(fileProperty.fileName); return fileProperty; }); } } exports.BundleMetadataType = BundleMetadataType; //# sourceMappingURL=bundleMetadataType.js.map