Skip to content

Commit

Permalink
feat: flag groups for deploy/retrieve (#626)
Browse files Browse the repository at this point in the history
* feat: flag groups for deploy/retrieve

* docs: apply suggestions from code review

Co-authored-by: Juliet Shackell <[email protected]>

---------

Co-authored-by: Juliet Shackell <[email protected]>
  • Loading branch information
mshanemc and jshackell-sfdc authored May 23, 2023
1 parent fcfd4a8 commit 9438659
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/commands/project/deploy/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ Messages.importMessagesDirectory(__dirname);
const messages = Messages.loadMessages('@salesforce/plugin-deploy-retrieve', 'deploy.metadata');

const exclusiveFlags = ['manifest', 'source-dir', 'metadata', 'metadata-dir'];
const mdapiFormatFlags = 'Metadata API Format';
const sourceFormatFlags = 'Source Format';
const testFlags = 'Test';
const destructiveFlags = 'Delete';

export default class DeployMetadata extends SfCommand<DeployResultJson> {
public static readonly description = messages.getMessage('description');
Expand Down Expand Up @@ -76,40 +80,46 @@ export default class DeployMetadata extends SfCommand<DeployResultJson> {
summary: messages.getMessage('flags.manifest.summary'),
exclusive: exclusiveFlags.filter((f) => f !== 'manifest'),
exists: true,
helpGroup: sourceFormatFlags,
}),
metadata: Flags.string({
char: 'm',
summary: messages.getMessage('flags.metadata.summary'),
multiple: true,
exclusive: exclusiveFlags.filter((f) => f !== 'metadata'),
helpGroup: sourceFormatFlags,
}),
'metadata-dir': fileOrDirFlag({
summary: messages.getMessage('flags.metadata-dir.summary'),
exclusive: exclusiveFlags.filter((f) => f !== 'metadata-dir'),
exists: true,
helpGroup: mdapiFormatFlags,
}),
'single-package': Flags.boolean({
summary: messages.getMessage('flags.single-package.summary'),
dependsOn: ['metadata-dir'],
helpGroup: mdapiFormatFlags,
}),
'source-dir': Flags.string({
char: 'd',
description: messages.getMessage('flags.source-dir.description'),
summary: messages.getMessage('flags.source-dir.summary'),
multiple: true,
exclusive: exclusiveFlags.filter((f) => f !== 'source-dir'),
helpGroup: sourceFormatFlags,
}),
'target-org': Flags.requiredOrg({
char: 'o',
description: messages.getMessage('flags.target-org.description'),
summary: messages.getMessage('flags.target-org.summary'),
required: true,
}),
tests: testsFlag,
tests: { ...testsFlag, helpGroup: testFlags },
'test-level': testLevelFlag({
description: messages.getMessage('flags.test-level.description'),
summary: messages.getMessage('flags.test-level.summary'),
options: [TestLevel.NoTestRun, TestLevel.RunSpecifiedTests, TestLevel.RunLocalTests, TestLevel.RunAllTestsInOrg],
helpGroup: testFlags,
}),
verbose: Flags.boolean({
summary: messages.getMessage('flags.verbose.summary'),
Expand All @@ -129,20 +139,28 @@ export default class DeployMetadata extends SfCommand<DeployResultJson> {
summary: messages.getMessage('flags.purge-on-delete.summary'),
dependsOn: ['manifest'],
relationships: [{ type: 'some', flags: ['pre-destructive-changes', 'post-destructive-changes'] }],
helpGroup: destructiveFlags,
}),
'pre-destructive-changes': Flags.file({
summary: messages.getMessage('flags.pre-destructive-changes.summary'),
dependsOn: ['manifest'],
helpGroup: destructiveFlags,
}),
'post-destructive-changes': Flags.file({
summary: messages.getMessage('flags.post-destructive-changes.summary'),
dependsOn: ['manifest'],
helpGroup: destructiveFlags,
}),
'coverage-formatters': { ...coverageFormattersFlag, helpGroup: testFlags },
junit: Flags.boolean({
summary: messages.getMessage('flags.junit.summary'),
dependsOn: ['coverage-formatters'],
helpGroup: testFlags,
}),
'coverage-formatters': coverageFormattersFlag,
junit: Flags.boolean({ summary: messages.getMessage('flags.junit.summary'), dependsOn: ['coverage-formatters'] }),
'results-dir': Flags.directory({
dependsOn: ['coverage-formatters'],
summary: messages.getMessage('flags.results-dir.summary'),
helpGroup: testFlags,
}),
};

Expand Down
6 changes: 6 additions & 0 deletions src/commands/project/retrieve/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ const messages = Messages.loadMessages('@salesforce/plugin-deploy-retrieve', 're
const mdTransferMessages = Messages.loadMessages('@salesforce/plugin-deploy-retrieve', 'metadata.transfer');

type Format = 'source' | 'metadata';
const mdapiFlagGroup = 'Metadata API Format';

export default class RetrieveMetadata extends SfCommand<RetrieveResultJson> {
public static readonly summary = messages.getMessage('summary');
public static readonly description = messages.getMessage('description');
Expand Down Expand Up @@ -76,6 +78,7 @@ export default class RetrieveMetadata extends SfCommand<RetrieveResultJson> {
summary: messages.getMessage('flags.single-package.summary'),
dependsOn: ['target-metadata-dir'],
exclusive: ['ignore-conflicts'],
helpGroup: mdapiFlagGroup,
}),
'source-dir': Flags.string({
char: 'd',
Expand All @@ -94,6 +97,7 @@ export default class RetrieveMetadata extends SfCommand<RetrieveResultJson> {
},
],
exclusive: ['ignore-conflicts'],
helpGroup: mdapiFlagGroup,
}),
'target-org': Flags.requiredOrg({
char: 'o',
Expand All @@ -114,11 +118,13 @@ export default class RetrieveMetadata extends SfCommand<RetrieveResultJson> {
summary: messages.getMessage('flags.unzip.summary'),
dependsOn: ['target-metadata-dir'],
exclusive: ['ignore-conflicts'],
helpGroup: mdapiFlagGroup,
}),
'zip-file-name': zipFileFlag({
summary: messages.getMessage('flags.zip-file-name.summary'),
dependsOn: ['target-metadata-dir'],
exclusive: ['ignore-conflicts'],
helpGroup: mdapiFlagGroup,
}),
};

Expand Down

0 comments on commit 9438659

Please sign in to comment.