salesforce-alm
Version:
This package contains tools, and APIs, for an improved salesforce.com developer experience.
60 lines (58 loc) • 3.35 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
*/
/* eslint-disable @typescript-eslint/no-unused-vars */
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocumentMetadataType = void 0;
const path = require("path");
const _ = require("lodash");
const workspaceFileState_1 = require("../workspaceFileState");
const MetadataRegistry = require("../metadataRegistry");
const workspaceElement_1 = require("../workspaceElement");
const PathUtil = require("../sourcePathUtil");
const inFolderMetadataType_1 = require("./inFolderMetadataType");
class DocumentMetadataType extends inFolderMetadataType_1.InFolderMetadataType {
getMdapiFormattedMetadataFileName(metadataFilePath) {
const workspaceContentFilePath = PathUtil.getContentPathWithNonStdExtFromMetadataPath(metadataFilePath);
const workspaceContentFileName = path.basename(workspaceContentFilePath);
return `${workspaceContentFileName}${MetadataRegistry.getMetadataFileExt()}`;
}
getAggregateMetadataFilePathFromWorkspacePath(workspacePath) {
const metadataFileName = `${PathUtil.getFileName(workspacePath)}.${this.typeDefObj.ext}${MetadataRegistry.getMetadataFileExt()}`;
return path.join(path.dirname(workspacePath), metadataFileName);
}
getAggregateFullNameFromFileProperty(fileProperty) {
return fileProperty.fullName.split('.')[0];
}
getWorkspaceElementsToDelete(aggregateMetadataPath, fileProperty) {
const workspaceElementsToDelete = [];
if (aggregateMetadataPath) {
const fullName = this.getAggregateFullNameFromFileProperty(fileProperty);
const existingDocumentFilePath = PathUtil.getContentPathWithNonStdExtFromMetadataPath(aggregateMetadataPath);
const existingDocumentFileTypeExtension = path.extname(existingDocumentFilePath).replace('.', '');
const retrievedDocumentExtension = path.extname(fileProperty.fullName).replace('.', '');
if (existingDocumentFileTypeExtension !== retrievedDocumentExtension) {
const deletedWorkspaceElement = new workspaceElement_1.WorkspaceElement(this.getMetadataName(), fullName, existingDocumentFilePath, workspaceFileState_1.WorkspaceFileState.DELETED, true);
workspaceElementsToDelete.push(deletedWorkspaceElement);
}
}
return workspaceElementsToDelete;
}
getOriginContentPathsForSourceConvert(metadataFilePath, workspaceVersion, unsupportedMimeTypes, forceIgnore) {
return Promise.resolve([PathUtil.getContentPathWithNonStdExtFromMetadataPath(metadataFilePath)]);
}
mainContentFileExists(metadataFilePath) {
const contentFilePath = PathUtil.getContentPathWithNonStdExtFromMetadataPath(metadataFilePath);
return !_.isNil(contentFilePath);
}
getAggregateFullNameFromComponentFailure(componentFailure) {
const componentFullName = componentFailure.fullName;
return componentFullName.substring(0, componentFullName.indexOf(path.extname(componentFullName)));
}
}
exports.DocumentMetadataType = DocumentMetadataType;
//# sourceMappingURL=documentMetadataType.js.map