Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/convert/convertContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 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
*/
import { dirname, join, resolve } from 'path';
import { join, resolve } from 'path';
import { getString, JsonArray, JsonMap } from '@salesforce/ts-types';
import { META_XML_SUFFIX, XML_NS_KEY, XML_NS_URL } from '../common';
import { ComponentSet } from '../collections';
Expand Down Expand Up @@ -273,7 +273,7 @@ class NonDecompositionFinalizer extends ConvertTransactionFinalizer<NonDecomposi
*/
private getAllComponentsOfType(defaultDirectory: string, componentType: string): SourceComponent[] {
// assumes that defaultDir is one level below project dir
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment still accurate now?

Copy link
Member Author

@cristiand391 cristiand391 Jul 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, the difference now is that it doesn't strip the last member in defaultDirectory, so for force:mdapi:convert -r mdapi -d test1/test2

const defaultDirectory = '/Users/cdominguez/code/sfdx-project/test1/test2';
const projectDir = resolve(defaultDirectory);

// projectDir would equal '/Users/cdominguez/code/sfdx-project/test1/test2'

...:thinking: wouldn't this cause SDR fail to find customlabels if you have MPDs in a project? Since projectDir will not be pointing to the root project dir.

this is the only place it's being called:

const allNonDecomposed = this.getAllComponentsOfType(

const projectDir = resolve(dirname(defaultDirectory));
const projectDir = resolve(defaultDirectory);
const unprocessedComponents = ComponentSet.fromSource({
fsPaths: [projectDir],
include: new ComponentSet([{ fullName: '*', type: componentType }]),
Expand Down
6 changes: 3 additions & 3 deletions test/convert/convertContext.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { Readable } from 'stream';
import { join } from 'path';
import { join, dirname } from 'path';

import { createSandbox } from 'sinon';
import chai = require('chai');
Expand Down Expand Up @@ -398,7 +398,7 @@ describe('Convert Transaction Constructs', () => {
const context = new ConvertContext();
const type = component.type;

// change the word first to 'updated'
// change the word 'third' to 'updated'
const updatedChild3Xml = {
...nonDecomposed.CHILD_3_XML,
value: nonDecomposed.CHILD_3_XML.value.replace('third', 'updated'),
Expand All @@ -417,7 +417,7 @@ describe('Convert Transaction Constructs', () => {
state.exampleComponent = component;
});

const result = await context.nonDecomposition.finalize(nonDecomposed.DEFAULT_DIR, TREE);
const result = await context.nonDecomposition.finalize(dirname(nonDecomposed.DEFAULT_DIR), TREE);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use dirname here to strip force-app from the path dir.
Screen Shot 2022-07-06 at 11 13 10

expect(result).to.deep.equal([{ component, writeInfos }]);
});
});
Expand Down