All files manifest.js

100% Statements 11/11
83.33% Branches 5/6
100% Functions 3/3
100% Lines 7/7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30  1x             1x 1x   1x   2x       2x           2x            
 
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;