From 9d9e04d90be0af6dfed32cf1b688f31032c82cfe Mon Sep 17 00:00:00 2001 From: Christopher Bohlman Date: Thu, 9 Nov 2023 21:51:53 -0500 Subject: [PATCH 1/2] fix: default --test-level flag if --tests present --- src/utils/flags.ts | 5 ++++- test/nuts/seeds/deploy.metadata.test-level.seed.ts | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/utils/flags.ts b/src/utils/flags.ts index df4b86d9..7cbe89d1 100644 --- a/src/utils/flags.ts +++ b/src/utils/flags.ts @@ -71,6 +71,10 @@ export const ensuredDirFlag = Flags.custom({ export const testLevelFlag = Flags.custom({ char: 'l', parse: (input) => Promise.resolve(input as TestLevel), + // eslint-disable-next-line @typescript-eslint/require-await + default: async (context) => { + if (context.flags.tests) return TestLevel.RunSpecifiedTests; + }, options: Object.values(TestLevel), }); @@ -91,7 +95,6 @@ export const zipFileFlag = Flags.custom({ export const testsFlag = Flags.string({ char: 't', multiple: true, - dependsOn: ['test-level'], summary: commonFlagMessages.getMessage('flags.tests.summary'), description: commonFlagMessages.getMessage('flags.tests.description'), // the old version allowed comma separated values, and the change is confusing enough to deserve a warning diff --git a/test/nuts/seeds/deploy.metadata.test-level.seed.ts b/test/nuts/seeds/deploy.metadata.test-level.seed.ts index 5991839d..5e07a25c 100644 --- a/test/nuts/seeds/deploy.metadata.test-level.seed.ts +++ b/test/nuts/seeds/deploy.metadata.test-level.seed.ts @@ -69,6 +69,15 @@ context('deploy metadata --test-level NUTs [name: %REPO_NAME%]', () => { }); await testkit.expect.specificApexTestsToBeRun(REPO.deploy.testLevel.specifiedTests); }); + + it('should set --test-level flag to (RunSpecifiedTests) if --tests flag is included', async () => { + const packages = testkit.packageNames.map((p) => `--source-dir ${p}`).join(' '); + const tests = REPO.deploy.testLevel.specifiedTests.join(','); + await testkit.deploy({ + args: `${packages} --tests ${tests}`, + }); + await testkit.expect.specificApexTestsToBeRun(REPO.deploy.testLevel.specifiedTests); + }); }); describe('test result format', () => { From 2a58fcaf6900868c61a1e1c45f3ab740d71a9b37 Mon Sep 17 00:00:00 2001 From: Christopher Bohlman Date: Thu, 9 Nov 2023 21:52:25 -0500 Subject: [PATCH 2/2] docs: minor typo --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index de3a8802..cb71291d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ # Add a new deploy command -The deploy-retrieve plugin does not have any commands for deploying or or retrieving specific pieces of a salesforce project (e.g. metadata to a scratch or functions to a compute environment). Instead, we ask developers to create their own plugin with those commands. In order for the `deploy` or `retrieve` commands to know about the individual plugins, each plugin must implement an [oclif hook](https://oclif.io/docs/hooks) which returns [`Deployers`](https://github.com/salesforcecli/plugin-deploy-retrieve-utils/blob/main/src/deployer.ts) and `Retirevers`. +The deploy-retrieve plugin does not have any commands for deploying or or retrieving specific pieces of a salesforce project (e.g. metadata to a scratch or functions to a compute environment). Instead, we ask developers to create their own plugin with those commands. In order for the `deploy` or `retrieve` commands to know about the individual plugins, each plugin must implement an [oclif hook](https://oclif.io/docs/hooks) which returns [`Deployers`](https://github.com/salesforcecli/plugin-deploy-retrieve-utils/blob/main/src/deployer.ts) and `Retrievers`. This method allows developers to own their own plugins while also allowing a simple way for the overarching `project` topic to interact with those plugins.