diff --git a/lib/env-bundler.js b/lib/env-bundler.js index 71b831c..e28c4f0 100644 --- a/lib/env-bundler.js +++ b/lib/env-bundler.js @@ -65,7 +65,7 @@ const componentDetailExtractors = { }), asset: (components) => components.map((c) => { - return { value: c.id, name: `(${c.type}) ${c.path}` }; + return { value: c.correlationCode, name: `(${c.type}) ${c.path}` }; }), group: (components) => components.map((c) => { @@ -115,7 +115,7 @@ const componentIdExtractors = { return c.name; }, asset: (c) => { - return c.id; + return c.correlationCode; }, group: (c) => { return c.code; @@ -160,7 +160,7 @@ const componentCodeExtractors = { return c.name; }, asset: (c) => { - return c.id; + return c.correlationCode; }, group: (c) => { return c.name; @@ -363,7 +363,12 @@ const componentResponseProcessor = { asset: async (response, token) => { const assets = response.data.payload; const schema = { - 'id': 'correlationCode', + 'id': [{ + key: 'correlationCode', + transform: function(id, source) { + return source.correlationCode !== undefined ? source.correlationCode : id; + } + }], 'type': 'type', 'name': 'name', 'description': 'description', @@ -516,7 +521,12 @@ const resourceExtractorByType = { const processContentAttribute = function(attribute) { const resourceSchema = { - 'id': 'id', + 'id': [{ + key: 'correlationCode', + transform: function(id, source) { + return source.correlationCode !== undefined ? source.correlationCode : id; + } + }], 'name': 'name', 'metadata': 'metadata', } @@ -568,7 +578,7 @@ const assetComponentDescriptorProcessor = function(type, location, code, compone const split = coreBaseApi.replace('//', '/').split('/'); const url = split[0] + '//' + split[1] + component.path; - const directory = `${location}/${typePlural}/${component.id}`; + const directory = `${location}/${typePlural}/${code}`; if (!fs.existsSync(directory)) { fs.mkdirSync(directory); @@ -731,6 +741,7 @@ async function recursiveTraverseFileTree (root, token) { const traversed = await recursiveTraverseFileTree(result.data.payload, token); return traversed.flat(); } else { + console.log('Collecting File: ' + resource.path); const response = await axios.get(apiUrlTable.resourceDetails.replace('{path}', resource.path), { headers: { Authorization: `Bearer ${token}` }, }); @@ -750,6 +761,7 @@ async function collectAllComponents () { const cmp = await getComponents(type); const dtls = componentDetailExtractors[type](cmp); allComponents[type] = dtls.map(d => d.value); + console.log(`Finished collecting ${typeToPlural(type)}`); })); return allComponents;