import path from 'path';
// There isn't a 1-1 mapping of item type in the portal items to "itemType"
// for a provisioning package. Eg. The item type "feature" or "widget"
// are both a provisioning item type of "catalog". But a portal item of
// "contentRepository" is the same provision item of "contentRepository".
const PROVISION_ITEM_TYPE_CATALOG = 'catalog';
const PROVISION_ITEM_TYPE_CONTENT_REPOSITORY = 'contentRepository';
const PORTAL_ITEM_TYPE_CONTENT_REPOSITORY = 'contentRepository';
const provisionItemType = (portalItem) => ((portalItem.type === PORTAL_ITEM_TYPE_CONTENT_REPOSITORY)
? PROVISION_ITEM_TYPE_CONTENT_REPOSITORY
: PROVISION_ITEM_TYPE_CATALOG);
const manifestEntry = (portalItem) => ({
name: portalItem.name,
itemType: provisionItemType(portalItem),
location: path.basename(portalItem.zip),
});
const createManifest = (items, name = 'catalog') => ({
name,
provisioningItems: items.map(manifestEntry),
});
export default createManifest;
|