Skip to content

Commit

Permalink
fix: add concise flag to retrieve preview
Browse files Browse the repository at this point in the history
  • Loading branch information
shetzel committed Dec 6, 2023
1 parent 0c3c9af commit b0045ed
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion command-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@
{
"command": "project:retrieve:preview",
"plugin": "@salesforce/plugin-deploy-retrieve",
"flags": ["ignore-conflicts", "json", "target-org"],
"flags": ["ignore-conflicts", "json", "target-org", "concise"],
"alias": ["retrieve:metadata:preview"],
"flagChars": ["c", "o"],
"flagAliases": []
Expand Down
4 changes: 4 additions & 0 deletions messages/retrieve.metadata.preview.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ This flag applies only to orgs that allow source tracking. It has no effect on o

Omit ignored files.

# flags.concise.description

Show only the changes that will be retrieved; omits files that are forceignored.

# flags.api-version.summary

Target API version for the deploy.
Expand Down
7 changes: 6 additions & 1 deletion src/commands/project/retrieve/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ export default class RetrieveMetadataPreview extends SfCommand<PreviewResult> {
summary: messages.getMessage('flags.target-org.summary'),
required: true,
}),
concise: Flags.boolean({
summary: messages.getMessage('flags.concise.summary'),
description: messages.getMessage('flags.concise.description'),
default: false,
}),
};

public async run(): Promise<PreviewResult> {
Expand Down Expand Up @@ -65,7 +70,7 @@ export default class RetrieveMetadataPreview extends SfCommand<PreviewResult> {
});

if (!this.jsonEnabled()) {
printTables(output, 'retrieve');
printTables(output, 'retrieve', flags.concise);
}
return output;
}
Expand Down
6 changes: 4 additions & 2 deletions src/utils/previewOutput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export const printIgnoredTable = (files: PreviewFile[], baseOperation: BaseOpera
}
};

export const printTables = (result: PreviewResult, baseOperation: BaseOperation): void => {
export const printTables = (result: PreviewResult, baseOperation: BaseOperation, concise = false): void => {
printConflictsTable(result.conflicts);
printDeleteTable(result.toDelete);
if (baseOperation === 'deploy') {
Expand All @@ -260,7 +260,9 @@ export const printTables = (result: PreviewResult, baseOperation: BaseOperation)
printRetrieveTable(result.toRetrieve);
}

printIgnoredTable(result.ignored, baseOperation);
if (!concise) {
printIgnoredTable(result.ignored, baseOperation);
}
};

export const getConflictFiles = async (stl?: SourceTracking, ignore = false): Promise<Set<string>> =>
Expand Down
9 changes: 9 additions & 0 deletions test/nuts/tracking/forceIgnore.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,14 @@ describe('forceignore changes', () => {
}).jsonOutput?.result;
expect(pullOutput?.files.length).to.equal(0);
});

it('will not display ignored files with --concise', () => {
// gets file into source tracking
const output = execCmd<PreviewResult>('project:retrieve:preview --concise', {
ensureExitCode: 0,
}).shellOutput.stdout;
expect(output).to.not.include("These files won't retrieve because they're ignored by your .forceignore file.");
expect(output).to.not.include('ApexClass CreatedClass');
});
});
});

0 comments on commit b0045ed

Please sign in to comment.