Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add concise flag to retrieve preview #831

Merged
merged 7 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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
shetzel marked this conversation as resolved.
Show resolved Hide resolved

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'),
shetzel marked this conversation as resolved.
Show resolved Hide resolved
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');
});
});
});