sf-delta-tests 0.0.27 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +146 -146
- package/lib/commands/delta/test-classes.d.ts +4 -1
- package/lib/commands/delta/test-classes.js +21 -13
- package/lib/commands/delta/test-classes.js.map +1 -1
- package/lib/services/flow-service.d.ts +41 -0
- package/lib/services/flow-service.js +142 -0
- package/lib/services/flow-service.js.map +1 -0
- package/lib/services/manifest-service.d.ts +5 -1
- package/lib/services/manifest-service.js +8 -7
- package/lib/services/manifest-service.js.map +1 -1
- package/messages/delta.test-classes.md +28 -24
- package/oclif.manifest.json +8 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,146 +1,146 @@
|
|
|
1
|
-
# sf-delta-tests
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/focus-tests) [](https://npmjs.org/package/focus-tests) [](https://raw.githubusercontent.com/salesforcecli/focus-tests/main/LICENSE.txt)
|
|
4
|
-
|
|
5
|
-
## Using the template
|
|
6
|
-
|
|
7
|
-
This repository provides a template for creating a plugin for the Salesforce CLI. To convert this template to a working plugin:
|
|
8
|
-
|
|
9
|
-
1. Please get in touch with the Platform CLI team. We want to help you develop your plugin.
|
|
10
|
-
2. Generate your plugin:
|
|
11
|
-
|
|
12
|
-
```
|
|
13
|
-
sf plugins install dev
|
|
14
|
-
sf dev generate plugin
|
|
15
|
-
|
|
16
|
-
git init -b main
|
|
17
|
-
git add . && git commit -m "chore: initial commit"
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
3. Create your plugin's repo in the salesforcecli github org
|
|
21
|
-
4. When you're ready, replace the contents of this README with the information you want.
|
|
22
|
-
|
|
23
|
-
## Learn about `sf` plugins
|
|
24
|
-
|
|
25
|
-
Salesforce CLI plugins are based on the [oclif plugin framework](<(https://oclif.io/docs/introduction.html)>). Read the [plugin developer guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_plugins.meta/sfdx_cli_plugins/cli_plugins_architecture_sf_cli.htm) to learn about Salesforce CLI plugin development.
|
|
26
|
-
|
|
27
|
-
This repository contains a lot of additional scripts and tools to help with general Salesforce node development and enforce coding standards. You should familiarize yourself with some of the [node developer packages](#tooling) used by Salesforce.
|
|
28
|
-
|
|
29
|
-
Additionally, there are some additional tests that the Salesforce CLI will enforce if this plugin is ever bundled with the CLI. These test are included by default under the `posttest` script and it is required to keep these tests active in your plugin if you plan to have it bundled.
|
|
30
|
-
|
|
31
|
-
### Tooling
|
|
32
|
-
|
|
33
|
-
- [@salesforce/core](https://github.com/forcedotcom/sfdx-core)
|
|
34
|
-
- [@salesforce/kit](https://github.com/forcedotcom/kit)
|
|
35
|
-
- [@salesforce/sf-plugins-core](https://github.com/salesforcecli/sf-plugins-core)
|
|
36
|
-
- [@salesforce/ts-types](https://github.com/forcedotcom/ts-types)
|
|
37
|
-
- [@salesforce/ts-sinon](https://github.com/forcedotcom/ts-sinon)
|
|
38
|
-
- [@salesforce/dev-config](https://github.com/forcedotcom/dev-config)
|
|
39
|
-
- [@salesforce/dev-scripts](https://github.com/forcedotcom/dev-scripts)
|
|
40
|
-
|
|
41
|
-
### Hooks
|
|
42
|
-
|
|
43
|
-
For cross clouds commands, e.g. `sf env list`, we utilize [oclif hooks](https://oclif.io/docs/hooks) to get the relevant information from installed plugins.
|
|
44
|
-
|
|
45
|
-
This plugin includes sample hooks in the [src/hooks directory](src/hooks). You'll just need to add the appropriate logic. You can also delete any of the hooks if they aren't required for your plugin.
|
|
46
|
-
|
|
47
|
-
# Everything past here is only a suggestion as to what should be in your specific plugin's description
|
|
48
|
-
|
|
49
|
-
This plugin is bundled with the [Salesforce CLI](https://developer.salesforce.com/tools/sfdxcli). For more information on the CLI, read the [getting started guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_intro.htm).
|
|
50
|
-
|
|
51
|
-
We always recommend using the latest version of these commands bundled with the CLI, however, you can install a specific version or tag if needed.
|
|
52
|
-
|
|
53
|
-
## Install
|
|
54
|
-
|
|
55
|
-
```bash
|
|
56
|
-
sf plugins install focus-tests@x.y.z
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## Issues
|
|
60
|
-
|
|
61
|
-
Please report any issues at https://github.com/forcedotcom/cli/issues
|
|
62
|
-
|
|
63
|
-
## Contributing
|
|
64
|
-
|
|
65
|
-
1. Please read our [Code of Conduct](CODE_OF_CONDUCT.md)
|
|
66
|
-
2. Create a new issue before starting your project so that we can keep track of
|
|
67
|
-
what you are trying to add/fix. That way, we can also offer suggestions or
|
|
68
|
-
let you know if there is already an effort in progress.
|
|
69
|
-
3. Fork this repository.
|
|
70
|
-
4. [Build the plugin locally](#build)
|
|
71
|
-
5. Create a _topic_ branch in your fork. Note, this step is recommended but technically not required if contributing using a fork.
|
|
72
|
-
6. Edit the code in your fork.
|
|
73
|
-
7. Write appropriate tests for your changes. Try to achieve at least 95% code coverage on any new code. No pull request will be accepted without unit tests.
|
|
74
|
-
8. Sign CLA (see [CLA](#cla) below).
|
|
75
|
-
9. Send us a pull request when you are done. We'll review your code, suggest any needed changes, and merge it in.
|
|
76
|
-
|
|
77
|
-
### CLA
|
|
78
|
-
|
|
79
|
-
External contributors will be required to sign a Contributor's License
|
|
80
|
-
Agreement. You can do so by going to https://cla.salesforce.com/sign-cla.
|
|
81
|
-
|
|
82
|
-
### Build
|
|
83
|
-
|
|
84
|
-
To build the plugin locally, make sure to have yarn installed and run the following commands:
|
|
85
|
-
|
|
86
|
-
```bash
|
|
87
|
-
# Clone the repository
|
|
88
|
-
git clone git@github.com:salesforcecli/focus-tests
|
|
89
|
-
|
|
90
|
-
# Install the dependencies and compile
|
|
91
|
-
yarn && yarn build
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
To use your plugin, run using the local `./bin/dev` or `./bin/dev.cmd` file.
|
|
95
|
-
|
|
96
|
-
```bash
|
|
97
|
-
# Run using local run file.
|
|
98
|
-
./bin/dev hello world
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
There should be no differences when running via the Salesforce CLI or using the local run file. However, it can be useful to link the plugin to do some additional testing or run your commands from anywhere on your machine.
|
|
102
|
-
|
|
103
|
-
```bash
|
|
104
|
-
# Link your plugin to the sf cli
|
|
105
|
-
sf plugins link .
|
|
106
|
-
# To verify
|
|
107
|
-
sf plugins
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
## Commands
|
|
111
|
-
|
|
112
|
-
<!-- commands -->
|
|
113
|
-
|
|
114
|
-
- [`sf delta test-classes`](#sf-delta-test-classes)
|
|
115
|
-
|
|
116
|
-
## `sf delta test-classes`
|
|
117
|
-
|
|
118
|
-
Calculates the tests needed to be ran based on the changed metadata given using the Salesforce Dependency API
|
|
119
|
-
|
|
120
|
-
```
|
|
121
|
-
USAGE
|
|
122
|
-
$ sf delta test-classes -o <value> -c <value> [--json] [-n <value>]
|
|
123
|
-
|
|
124
|
-
FLAGS
|
|
125
|
-
-c, --changed-metadata=<value> (required) Comma seperated list of changed metadata.
|
|
126
|
-
-n, --name=<value> Description of a flag.
|
|
127
|
-
-o, --target-org=<value> (required) The org you want to check the dependencies against.
|
|
128
|
-
|
|
129
|
-
GLOBAL FLAGS
|
|
130
|
-
--json Format output as json.
|
|
131
|
-
|
|
132
|
-
DESCRIPTION
|
|
133
|
-
Calculates the tests needed to be ran based on the changed metadata given using the Salesforce Dependency API
|
|
134
|
-
|
|
135
|
-
Calculates the tests needed to be ran based on the changed metadata given using the Salesforce Dependency API
|
|
136
|
-
|
|
137
|
-
EXAMPLES
|
|
138
|
-
$ sf delta test-classes
|
|
139
|
-
|
|
140
|
-
FLAG DESCRIPTIONS
|
|
141
|
-
-n, --name=<value> Description of a flag.
|
|
142
|
-
|
|
143
|
-
More information about a flag. Don't repeat the summary.
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
<!-- commandsstop -->
|
|
1
|
+
# sf-delta-tests
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/focus-tests) [](https://npmjs.org/package/focus-tests) [](https://raw.githubusercontent.com/salesforcecli/focus-tests/main/LICENSE.txt)
|
|
4
|
+
|
|
5
|
+
## Using the template
|
|
6
|
+
|
|
7
|
+
This repository provides a template for creating a plugin for the Salesforce CLI. To convert this template to a working plugin:
|
|
8
|
+
|
|
9
|
+
1. Please get in touch with the Platform CLI team. We want to help you develop your plugin.
|
|
10
|
+
2. Generate your plugin:
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
sf plugins install dev
|
|
14
|
+
sf dev generate plugin
|
|
15
|
+
|
|
16
|
+
git init -b main
|
|
17
|
+
git add . && git commit -m "chore: initial commit"
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
3. Create your plugin's repo in the salesforcecli github org
|
|
21
|
+
4. When you're ready, replace the contents of this README with the information you want.
|
|
22
|
+
|
|
23
|
+
## Learn about `sf` plugins
|
|
24
|
+
|
|
25
|
+
Salesforce CLI plugins are based on the [oclif plugin framework](<(https://oclif.io/docs/introduction.html)>). Read the [plugin developer guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_plugins.meta/sfdx_cli_plugins/cli_plugins_architecture_sf_cli.htm) to learn about Salesforce CLI plugin development.
|
|
26
|
+
|
|
27
|
+
This repository contains a lot of additional scripts and tools to help with general Salesforce node development and enforce coding standards. You should familiarize yourself with some of the [node developer packages](#tooling) used by Salesforce.
|
|
28
|
+
|
|
29
|
+
Additionally, there are some additional tests that the Salesforce CLI will enforce if this plugin is ever bundled with the CLI. These test are included by default under the `posttest` script and it is required to keep these tests active in your plugin if you plan to have it bundled.
|
|
30
|
+
|
|
31
|
+
### Tooling
|
|
32
|
+
|
|
33
|
+
- [@salesforce/core](https://github.com/forcedotcom/sfdx-core)
|
|
34
|
+
- [@salesforce/kit](https://github.com/forcedotcom/kit)
|
|
35
|
+
- [@salesforce/sf-plugins-core](https://github.com/salesforcecli/sf-plugins-core)
|
|
36
|
+
- [@salesforce/ts-types](https://github.com/forcedotcom/ts-types)
|
|
37
|
+
- [@salesforce/ts-sinon](https://github.com/forcedotcom/ts-sinon)
|
|
38
|
+
- [@salesforce/dev-config](https://github.com/forcedotcom/dev-config)
|
|
39
|
+
- [@salesforce/dev-scripts](https://github.com/forcedotcom/dev-scripts)
|
|
40
|
+
|
|
41
|
+
### Hooks
|
|
42
|
+
|
|
43
|
+
For cross clouds commands, e.g. `sf env list`, we utilize [oclif hooks](https://oclif.io/docs/hooks) to get the relevant information from installed plugins.
|
|
44
|
+
|
|
45
|
+
This plugin includes sample hooks in the [src/hooks directory](src/hooks). You'll just need to add the appropriate logic. You can also delete any of the hooks if they aren't required for your plugin.
|
|
46
|
+
|
|
47
|
+
# Everything past here is only a suggestion as to what should be in your specific plugin's description
|
|
48
|
+
|
|
49
|
+
This plugin is bundled with the [Salesforce CLI](https://developer.salesforce.com/tools/sfdxcli). For more information on the CLI, read the [getting started guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_intro.htm).
|
|
50
|
+
|
|
51
|
+
We always recommend using the latest version of these commands bundled with the CLI, however, you can install a specific version or tag if needed.
|
|
52
|
+
|
|
53
|
+
## Install
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
sf plugins install focus-tests@x.y.z
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Issues
|
|
60
|
+
|
|
61
|
+
Please report any issues at https://github.com/forcedotcom/cli/issues
|
|
62
|
+
|
|
63
|
+
## Contributing
|
|
64
|
+
|
|
65
|
+
1. Please read our [Code of Conduct](CODE_OF_CONDUCT.md)
|
|
66
|
+
2. Create a new issue before starting your project so that we can keep track of
|
|
67
|
+
what you are trying to add/fix. That way, we can also offer suggestions or
|
|
68
|
+
let you know if there is already an effort in progress.
|
|
69
|
+
3. Fork this repository.
|
|
70
|
+
4. [Build the plugin locally](#build)
|
|
71
|
+
5. Create a _topic_ branch in your fork. Note, this step is recommended but technically not required if contributing using a fork.
|
|
72
|
+
6. Edit the code in your fork.
|
|
73
|
+
7. Write appropriate tests for your changes. Try to achieve at least 95% code coverage on any new code. No pull request will be accepted without unit tests.
|
|
74
|
+
8. Sign CLA (see [CLA](#cla) below).
|
|
75
|
+
9. Send us a pull request when you are done. We'll review your code, suggest any needed changes, and merge it in.
|
|
76
|
+
|
|
77
|
+
### CLA
|
|
78
|
+
|
|
79
|
+
External contributors will be required to sign a Contributor's License
|
|
80
|
+
Agreement. You can do so by going to https://cla.salesforce.com/sign-cla.
|
|
81
|
+
|
|
82
|
+
### Build
|
|
83
|
+
|
|
84
|
+
To build the plugin locally, make sure to have yarn installed and run the following commands:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# Clone the repository
|
|
88
|
+
git clone git@github.com:salesforcecli/focus-tests
|
|
89
|
+
|
|
90
|
+
# Install the dependencies and compile
|
|
91
|
+
yarn && yarn build
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
To use your plugin, run using the local `./bin/dev` or `./bin/dev.cmd` file.
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
# Run using local run file.
|
|
98
|
+
./bin/dev hello world
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
There should be no differences when running via the Salesforce CLI or using the local run file. However, it can be useful to link the plugin to do some additional testing or run your commands from anywhere on your machine.
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
# Link your plugin to the sf cli
|
|
105
|
+
sf plugins link .
|
|
106
|
+
# To verify
|
|
107
|
+
sf plugins
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Commands
|
|
111
|
+
|
|
112
|
+
<!-- commands -->
|
|
113
|
+
|
|
114
|
+
- [`sf delta test-classes`](#sf-delta-test-classes)
|
|
115
|
+
|
|
116
|
+
## `sf delta test-classes`
|
|
117
|
+
|
|
118
|
+
Calculates the tests needed to be ran based on the changed metadata given using the Salesforce Dependency API
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
USAGE
|
|
122
|
+
$ sf delta test-classes -o <value> -c <value> [--json] [-n <value>]
|
|
123
|
+
|
|
124
|
+
FLAGS
|
|
125
|
+
-c, --changed-metadata=<value> (required) Comma seperated list of changed metadata.
|
|
126
|
+
-n, --name=<value> Description of a flag.
|
|
127
|
+
-o, --target-org=<value> (required) The org you want to check the dependencies against.
|
|
128
|
+
|
|
129
|
+
GLOBAL FLAGS
|
|
130
|
+
--json Format output as json.
|
|
131
|
+
|
|
132
|
+
DESCRIPTION
|
|
133
|
+
Calculates the tests needed to be ran based on the changed metadata given using the Salesforce Dependency API
|
|
134
|
+
|
|
135
|
+
Calculates the tests needed to be ran based on the changed metadata given using the Salesforce Dependency API
|
|
136
|
+
|
|
137
|
+
EXAMPLES
|
|
138
|
+
$ sf delta test-classes
|
|
139
|
+
|
|
140
|
+
FLAG DESCRIPTIONS
|
|
141
|
+
-n, --name=<value> Description of a flag.
|
|
142
|
+
|
|
143
|
+
More information about a flag. Don't repeat the summary.
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
<!-- commandsstop -->
|
|
@@ -5,6 +5,7 @@ import { ApexClassService } from '../../services/apex-class-service';
|
|
|
5
5
|
import { ManifestService } from '../../services/manifest-service';
|
|
6
6
|
import { OutputService } from '../../services/output-service';
|
|
7
7
|
import { CliService } from '../../services/cli-service';
|
|
8
|
+
import { FlowService } from '../../services/flow-service';
|
|
8
9
|
export type DeltaTestClassesResult = {
|
|
9
10
|
testNames: string[];
|
|
10
11
|
cli: string;
|
|
@@ -17,12 +18,14 @@ export default class TestClasses extends SfCommand<DeltaTestClassesResult> {
|
|
|
17
18
|
'target-org': import("@oclif/core/lib/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
18
19
|
'package-path': import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
19
20
|
'always-run-test': import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
21
|
+
'include-all-flows': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
20
22
|
};
|
|
21
23
|
private dependencyService;
|
|
22
24
|
private apexClassService;
|
|
23
25
|
private outputService;
|
|
24
26
|
private manifestService;
|
|
25
27
|
private cliService;
|
|
26
|
-
|
|
28
|
+
private flowService;
|
|
29
|
+
constructor(argv: string[], config: Config, dependencyService?: DependencyService, apexClassService?: ApexClassService, outputService?: OutputService, manifestService?: ManifestService, cliService?: CliService, flowService?: FlowService);
|
|
27
30
|
run(): Promise<DeltaTestClassesResult>;
|
|
28
31
|
}
|
|
@@ -8,16 +8,18 @@ const apex_class_service_1 = require("../../services/apex-class-service");
|
|
|
8
8
|
const manifest_service_1 = require("../../services/manifest-service");
|
|
9
9
|
const output_service_1 = require("../../services/output-service");
|
|
10
10
|
const cli_service_1 = require("../../services/cli-service");
|
|
11
|
+
const flow_service_1 = require("../../services/flow-service");
|
|
11
12
|
core_1.Messages.importMessagesDirectory(__dirname);
|
|
12
13
|
const messages = core_1.Messages.loadMessages('sf-delta-tests', 'delta.test-classes');
|
|
13
14
|
class TestClasses extends sf_plugins_core_1.SfCommand {
|
|
14
|
-
constructor(argv, config, dependencyService = new dependency_service_1.DependencyService(), apexClassService = new apex_class_service_1.ApexClassService(), outputService = new output_service_1.OutputService(), manifestService = new manifest_service_1.ManifestService(), cliService = new cli_service_1.CliService()) {
|
|
15
|
+
constructor(argv, config, dependencyService = new dependency_service_1.DependencyService(), apexClassService = new apex_class_service_1.ApexClassService(), outputService = new output_service_1.OutputService(), manifestService = new manifest_service_1.ManifestService(), cliService = new cli_service_1.CliService(), flowService = new flow_service_1.FlowService()) {
|
|
15
16
|
super(argv, config);
|
|
16
17
|
this.dependencyService = dependencyService;
|
|
17
18
|
this.apexClassService = apexClassService;
|
|
18
19
|
this.outputService = outputService;
|
|
19
20
|
this.manifestService = manifestService;
|
|
20
21
|
this.cliService = cliService;
|
|
22
|
+
this.flowService = flowService;
|
|
21
23
|
}
|
|
22
24
|
async run() {
|
|
23
25
|
try {
|
|
@@ -29,12 +31,20 @@ class TestClasses extends sf_plugins_core_1.SfCommand {
|
|
|
29
31
|
this.debug('Getting dependencies from SF');
|
|
30
32
|
// Download all dependencies from SF
|
|
31
33
|
const combinedApexClassData = await this.dependencyService.getDependenciesByObjects();
|
|
34
|
+
this.debug('combinedApexClassData', combinedApexClassData);
|
|
32
35
|
// Write into output folder
|
|
33
36
|
await this.outputService.dependencyData(combinedApexClassData);
|
|
34
37
|
this.debug(`Loading metadata from ${flags['package-path']}`);
|
|
35
38
|
// Get manifest data and transform that into a list of metadata
|
|
36
39
|
const manifestData = await this.manifestService.parseManifest(flags['package-path']);
|
|
37
|
-
const
|
|
40
|
+
const changedMetadataWithType = this.manifestService.extractMetadataComponentsWithType(manifestData);
|
|
41
|
+
const flowNames = await this.flowService.getFlowNames(changedMetadataWithType, flags['include-all-flows']);
|
|
42
|
+
const flowTriggerObjectNames = await this.flowService.getTriggerObjectsFromFlows(flowNames);
|
|
43
|
+
const changedMetadata = (0, lodash_1.uniq)([
|
|
44
|
+
...flowNames,
|
|
45
|
+
...flowTriggerObjectNames,
|
|
46
|
+
...changedMetadataWithType.map((c) => c.name),
|
|
47
|
+
]);
|
|
38
48
|
this.debug({ manifestData: manifestData.components, changedMetadata });
|
|
39
49
|
// If no meaningful changed metadata, no need to run tests (layout changes don't need tests!)
|
|
40
50
|
if (changedMetadata.length === 0) {
|
|
@@ -45,22 +55,15 @@ class TestClasses extends sf_plugins_core_1.SfCommand {
|
|
|
45
55
|
cli: this.cliService.noTests(flags['always-run-test']),
|
|
46
56
|
};
|
|
47
57
|
}
|
|
48
|
-
// Too many changes, just run all
|
|
49
|
-
if (changedMetadata.length > 40) {
|
|
50
|
-
this.debug(`Found over 40 changed metadata items (${changedMetadata.length}), running all tests`);
|
|
51
|
-
this.log(this.cliService.allTests());
|
|
52
|
-
return { testNames: [], cli: this.cliService.allTests() };
|
|
53
|
-
}
|
|
54
58
|
this.debug('Calculating the related apex classes...');
|
|
55
59
|
// The magic function. From the changed metadata get all the Apex Classes that could be connected to the changed metadata
|
|
56
60
|
const classList = this.dependencyService.getRelatedApexClasses(combinedApexClassData, changedMetadata);
|
|
57
|
-
const unknownEntities = (0, lodash_1.difference)(changedMetadata, classList);
|
|
58
61
|
this.debug({ classList });
|
|
59
|
-
this.debug({ unknownEntities });
|
|
60
62
|
this.debug('Filtering the apex classes to only tests...');
|
|
61
|
-
// Filter the total class list to only tests
|
|
62
|
-
const testNames = await this.apexClassService.filterApexTest(
|
|
63
|
-
this.
|
|
63
|
+
// Filter the total class list to only tests
|
|
64
|
+
const testNames = await this.apexClassService.filterApexTest(classList);
|
|
65
|
+
const simpleTestNames = this.apexClassService.filterApexTestSimple(classList);
|
|
66
|
+
this.debug({ testNames, simpleTestNames });
|
|
64
67
|
if (flags['always-run-test']) {
|
|
65
68
|
testNames.push(...flags['always-run-test']);
|
|
66
69
|
}
|
|
@@ -109,6 +112,11 @@ TestClasses.flags = {
|
|
|
109
112
|
summary: messages.getMessage('flags.always-run-test.summary'),
|
|
110
113
|
multiple: true,
|
|
111
114
|
}),
|
|
115
|
+
'include-all-flows': sf_plugins_core_1.Flags.boolean({
|
|
116
|
+
summary: messages.getMessage('flags.include-all-flows.summary'),
|
|
117
|
+
default: true,
|
|
118
|
+
allowNo: true,
|
|
119
|
+
}),
|
|
112
120
|
};
|
|
113
121
|
exports.default = TestClasses;
|
|
114
122
|
//# sourceMappingURL=test-classes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-classes.js","sourceRoot":"","sources":["../../../src/commands/delta/test-classes.ts"],"names":[],"mappings":";;AAAA,iEAA+D;AAC/D,2CAA4C;AAE5C,
|
|
1
|
+
{"version":3,"file":"test-classes.js","sourceRoot":"","sources":["../../../src/commands/delta/test-classes.ts"],"names":[],"mappings":";;AAAA,iEAA+D;AAC/D,2CAA4C;AAE5C,mCAA8B;AAC9B,0EAAsE;AACtE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E,sBAAsB;KAChC,CAAC;IACF,iBAAiB,EAAE,uBAAK,CAAC,MAAM,CAAC;QAC9B,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,+BAA+B,CAAC;QAC7D,QAAQ,EAAE,IAAI;KACf,CAAC;IACF,mBAAmB,EAAE,uBAAK,CAAC,OAAO,CAAC;QACjC,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,iCAAiC,CAAC;QAC/D,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,IAAI;KACd,CAAC;CACH,CAAC;kBA3BiB,WAAW"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { MetadataComponent } from './manifest-service';
|
|
2
|
+
export type FlowMetadata = {
|
|
3
|
+
apiName: string;
|
|
4
|
+
triggerType?: string;
|
|
5
|
+
processType?: string;
|
|
6
|
+
triggerObjectOrEvent?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare class FlowService {
|
|
9
|
+
private alwaysArray;
|
|
10
|
+
private xmlParser;
|
|
11
|
+
private logger;
|
|
12
|
+
/**
|
|
13
|
+
* Gets Flow names that require test coverage.
|
|
14
|
+
* If includeAllFlows is true, and any changed flow requires tests, return changed flows plus all flows that require tests.
|
|
15
|
+
* Otherwise, returns only the changed flows.
|
|
16
|
+
*/
|
|
17
|
+
getFlowNames(changedMetadataWithType: MetadataComponent[], includeAllFlows: boolean): Promise<string[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Extracts Flow metadata from local Flow definition files.
|
|
20
|
+
* Parses .flow-meta.xml files to get trigger information.
|
|
21
|
+
*/
|
|
22
|
+
getFlowMetadata(flowNames: string[], rootPath?: string): Promise<FlowMetadata[]>;
|
|
23
|
+
/**
|
|
24
|
+
* Gets trigger objects from Flow metadata.
|
|
25
|
+
*/
|
|
26
|
+
getTriggerObjectsFromFlows(flowNames: string[], rootPath?: string): Promise<Set<string>>;
|
|
27
|
+
/**
|
|
28
|
+
* Gets all Flow API names from local Flow definition files.
|
|
29
|
+
*/
|
|
30
|
+
getAllFlowNames(rootPath?: string): Promise<string[]>;
|
|
31
|
+
/**
|
|
32
|
+
* Determines if a Flow requires test coverage.
|
|
33
|
+
* All processes and autolaunched flows require coverage, except Screen Flows.
|
|
34
|
+
*/
|
|
35
|
+
private flowRequiresTestCoverage;
|
|
36
|
+
/**
|
|
37
|
+
* Parses a Flow XML definition to extract trigger information.
|
|
38
|
+
*/
|
|
39
|
+
private parseFlowXml;
|
|
40
|
+
private isNotNullOrUndefined;
|
|
41
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable class-methods-use-this */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.FlowService = void 0;
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const promises_1 = require("fs/promises");
|
|
7
|
+
const glob_1 = require("glob");
|
|
8
|
+
const fast_xml_parser_1 = require("fast-xml-parser");
|
|
9
|
+
const core_1 = require("@salesforce/core");
|
|
10
|
+
const lodash_1 = require("lodash");
|
|
11
|
+
const object_types_1 = require("../elements/object-types");
|
|
12
|
+
class FlowService {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.alwaysArray = ['Flow.processMetadataValues'];
|
|
15
|
+
this.xmlParser = new fast_xml_parser_1.XMLParser({
|
|
16
|
+
ignoreAttributes: false,
|
|
17
|
+
parseAttributeValue: false,
|
|
18
|
+
trimValues: true,
|
|
19
|
+
isArray: (_, jpath) => this.alwaysArray.includes(jpath),
|
|
20
|
+
});
|
|
21
|
+
this.logger = new core_1.Logger('FlowService');
|
|
22
|
+
this.isNotNullOrUndefined = (value) => value !== undefined && value !== null;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Gets Flow names that require test coverage.
|
|
26
|
+
* If includeAllFlows is true, and any changed flow requires tests, return changed flows plus all flows that require tests.
|
|
27
|
+
* Otherwise, returns only the changed flows.
|
|
28
|
+
*/
|
|
29
|
+
async getFlowNames(changedMetadataWithType, includeAllFlows) {
|
|
30
|
+
const changedFlows = changedMetadataWithType.filter((m) => m.type === object_types_1.FLOW).map((m) => m.name);
|
|
31
|
+
if (changedFlows.length === 0) {
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
// Get metadata for changed flows to check if any require test coverage
|
|
35
|
+
const changedFlowMetadata = await this.getFlowMetadata(changedFlows);
|
|
36
|
+
const changedFlowsRequiringTests = changedFlowMetadata.filter((flow) => this.flowRequiresTestCoverage(flow));
|
|
37
|
+
this.logger.info('changedFlowMetadata', changedFlowMetadata);
|
|
38
|
+
this.logger.info('changedFlowsRequiringTests', changedFlowsRequiringTests);
|
|
39
|
+
if (changedFlowsRequiringTests.length && includeAllFlows) {
|
|
40
|
+
// Get all flows and filter to only those requiring test coverage
|
|
41
|
+
const allFlowNames = await this.getAllFlowNames();
|
|
42
|
+
const allFlowsRequiringTests = (await this.getFlowMetadata(allFlowNames))
|
|
43
|
+
.filter((flow) => this.flowRequiresTestCoverage(flow))
|
|
44
|
+
.map((flow) => flow.apiName);
|
|
45
|
+
this.logger.info('changedFlows', changedFlows);
|
|
46
|
+
this.logger.info('allFlowNames', allFlowNames);
|
|
47
|
+
this.logger.info('allFlowsRequiringTests', allFlowsRequiringTests);
|
|
48
|
+
return (0, lodash_1.uniq)([...changedFlows, ...allFlowsRequiringTests]);
|
|
49
|
+
}
|
|
50
|
+
return changedFlows;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Extracts Flow metadata from local Flow definition files.
|
|
54
|
+
* Parses .flow-meta.xml files to get trigger information.
|
|
55
|
+
*/
|
|
56
|
+
async getFlowMetadata(flowNames, rootPath = 'force-app/main/default/flows') {
|
|
57
|
+
if (flowNames.length === 0) {
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
const flowPaths = await Promise.all(flowNames.map(async (flowName) => {
|
|
61
|
+
const globPattern = `**/${flowName}.flow-meta.xml`;
|
|
62
|
+
return (0, glob_1.glob)(globPattern, { cwd: rootPath });
|
|
63
|
+
}));
|
|
64
|
+
const flowMetadataPromises = flowPaths.flat().map(async (flowPath) => {
|
|
65
|
+
const fullPath = `${rootPath}/${flowPath}`;
|
|
66
|
+
const parsedPath = (0, path_1.parse)(fullPath);
|
|
67
|
+
const apiName = parsedPath.name.replace('.flow-meta', '');
|
|
68
|
+
try {
|
|
69
|
+
const fileContent = await (0, promises_1.readFile)(fullPath, 'utf8');
|
|
70
|
+
const flowDef = this.parseFlowXml(fileContent);
|
|
71
|
+
return {
|
|
72
|
+
apiName,
|
|
73
|
+
triggerType: flowDef.triggerType,
|
|
74
|
+
processType: flowDef.processType,
|
|
75
|
+
triggerObjectOrEvent: flowDef.triggerObjectOrEvent,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
// If we can't parse a Flow file, skip it but log the issue
|
|
80
|
+
this.logger.warn(`Failed to parse Flow file ${fullPath}:`, error);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
const flowMetadata = await Promise.all(flowMetadataPromises);
|
|
84
|
+
return flowMetadata.filter(this.isNotNullOrUndefined);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Gets trigger objects from Flow metadata.
|
|
88
|
+
*/
|
|
89
|
+
async getTriggerObjectsFromFlows(flowNames, rootPath = 'force-app/main/default/flows') {
|
|
90
|
+
const flowMetadata = (await this.getFlowMetadata(flowNames, rootPath))
|
|
91
|
+
.map((flow) => flow.triggerObjectOrEvent)
|
|
92
|
+
.filter(this.isNotNullOrUndefined);
|
|
93
|
+
return new Set(flowMetadata);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Gets all Flow API names from local Flow definition files.
|
|
97
|
+
*/
|
|
98
|
+
async getAllFlowNames(rootPath = 'force-app/main/default/flows') {
|
|
99
|
+
const flowPaths = await (0, glob_1.glob)('**/*.flow-meta.xml', { cwd: rootPath });
|
|
100
|
+
return flowPaths.map((flowPath) => {
|
|
101
|
+
const parsedPath = (0, path_1.parse)(flowPath);
|
|
102
|
+
return parsedPath.name.replace('.flow-meta', '');
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Determines if a Flow requires test coverage.
|
|
107
|
+
* All processes and autolaunched flows require coverage, except Screen Flows.
|
|
108
|
+
*/
|
|
109
|
+
flowRequiresTestCoverage(flow) {
|
|
110
|
+
// Screen flows are exempt from test coverage requirements
|
|
111
|
+
return flow.triggerType !== undefined || flow.processType !== 'Flow';
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Parses a Flow XML definition to extract trigger information.
|
|
115
|
+
*/
|
|
116
|
+
parseFlowXml(xmlContent) {
|
|
117
|
+
const result = this.xmlParser.parse(xmlContent);
|
|
118
|
+
const flow = result.Flow;
|
|
119
|
+
if (!flow) {
|
|
120
|
+
return {};
|
|
121
|
+
}
|
|
122
|
+
// Extract trigger type and object from the Flow definition
|
|
123
|
+
const triggerType = flow.start?.triggerType ?? flow.triggerType;
|
|
124
|
+
const processType = flow.processType;
|
|
125
|
+
let triggerObjectOrEvent = flow.start?.object;
|
|
126
|
+
// Check for processMetadataValues which might contain trigger info for older flows
|
|
127
|
+
if (flow.processMetadataValues) {
|
|
128
|
+
const metadataValues = flow.processMetadataValues;
|
|
129
|
+
const objectTypeMetadata = metadataValues.find((metadata) => metadata.name === 'ObjectType' && metadata.value?.stringValue);
|
|
130
|
+
if (objectTypeMetadata?.value?.stringValue) {
|
|
131
|
+
triggerObjectOrEvent = objectTypeMetadata.value.stringValue;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
triggerType,
|
|
136
|
+
processType,
|
|
137
|
+
triggerObjectOrEvent,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
exports.FlowService = FlowService;
|
|
142
|
+
//# sourceMappingURL=flow-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow-service.js","source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CAAC,qBAAqB,CAAC;YAElD,MAAM,kBAAkB,GAAG,cAAc,CAAC,IAAI,CAC5C,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY,IAAI,QAAQ,CAAC,KAAK,EAAE,WAAW,CAC5E,CAAC;YAEF,IAAI,kBAAkB,EAAE,KAAK,EAAE,WAAW,EAAE;gBAC1C,oBAAoB,GAAG,kBAAkB,CAAC,KAAK,CAAC,WAAW,CAAC;aAC7D;SACF;QAED,OAAO;YACL,WAAW;YACX,WAAW;YACX,oBAAoB;SACrB,CAAC;IACJ,CAAC;CAGF;AAvKD,kCAuKC"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { ResolveManifestResult } from '@salesforce/source-deploy-retrieve/lib/src/resolve/manifestResolver';
|
|
2
|
+
export type MetadataComponent = {
|
|
3
|
+
name: string;
|
|
4
|
+
type: string;
|
|
5
|
+
};
|
|
2
6
|
export declare class ManifestService {
|
|
3
7
|
parseManifest(path?: string): Promise<ResolveManifestResult>;
|
|
4
|
-
|
|
8
|
+
extractMetadataComponentsWithType(manifestData: ResolveManifestResult): MetadataComponent[];
|
|
5
9
|
}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/* eslint-disable class-methods-use-this */
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.ManifestService = void 0;
|
|
4
5
|
const source_deploy_retrieve_1 = require("@salesforce/source-deploy-retrieve");
|
|
5
6
|
const object_types_1 = require("../elements/object-types");
|
|
6
7
|
class ManifestService {
|
|
7
|
-
// eslint-disable-next-line class-methods-use-this
|
|
8
8
|
async parseManifest(path = 'manifest/package.xml') {
|
|
9
9
|
const manifestResolver = new source_deploy_retrieve_1.ManifestResolver();
|
|
10
10
|
return manifestResolver.resolve(path);
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const componentNames = new Set();
|
|
12
|
+
extractMetadataComponentsWithType(manifestData) {
|
|
13
|
+
const componentMap = new Map();
|
|
15
14
|
for (const component of manifestData.components) {
|
|
16
15
|
// Metadata can have a wildcard, we don't support this today
|
|
17
16
|
if (component.fullName === '*') {
|
|
@@ -22,15 +21,17 @@ class ManifestService {
|
|
|
22
21
|
continue;
|
|
23
22
|
}
|
|
24
23
|
// Children components, we want to get the parent. Example: `Account.Name` -> `Account`
|
|
24
|
+
let name;
|
|
25
25
|
if (component.fullName.includes('.')) {
|
|
26
26
|
const splitComponentName = component.fullName.split('.');
|
|
27
|
-
|
|
27
|
+
name = splitComponentName[0];
|
|
28
28
|
}
|
|
29
29
|
else {
|
|
30
|
-
|
|
30
|
+
name = component.fullName;
|
|
31
31
|
}
|
|
32
|
+
componentMap.set(name, { name, type: component.type.name });
|
|
32
33
|
}
|
|
33
|
-
return Array.from(
|
|
34
|
+
return Array.from(componentMap.values());
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
exports.ManifestService = ManifestService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest-service.js","sourceRoot":"","sources":["../../src/services/manifest-service.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"manifest-service.js","sourceRoot":"","sources":["../../src/services/manifest-service.ts"],"names":[],"mappings":";AAAA,2CAA2C;;;AAE3C,+EAAsE;AAEtE,2DAAqE;AAOrE,MAAa,eAAe;IACnB,KAAK,CAAC,aAAa,CAAC,IAAI,GAAG,sBAAsB;QACtD,MAAM,gBAAgB,GAAG,IAAI,yCAAgB,EAAE,CAAC;QAChD,OAAO,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IAEM,iCAAiC,CAAC,YAAmC;QAC1E,MAAM,YAAY,GAAG,IAAI,GAAG,EAA6B,CAAC;QAC1D,KAAK,MAAM,SAAS,IAAI,YAAY,CAAC,UAAU,EAAE;YAC/C,4DAA4D;YAC5D,IAAI,SAAS,CAAC,QAAQ,KAAK,GAAG,EAAE;gBAC9B,SAAS;aACV;YAED,4DAA4D;YAC5D,IAAI,CAAC,wCAAyB,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;gBAC5D,SAAS;aACV;YAED,uFAAuF;YACvF,IAAI,IAAY,CAAC;YACjB,IAAI,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;gBACpC,MAAM,kBAAkB,GAAG,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBACzD,IAAI,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC;aAC9B;iBAAM;gBACL,IAAI,GAAG,SAAS,CAAC,QAAQ,CAAC;aAC3B;YAED,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;SAC7D;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;IAC3C,CAAC;CACF;AAjCD,0CAiCC"}
|
|
@@ -1,24 +1,28 @@
|
|
|
1
|
-
# summary
|
|
2
|
-
|
|
3
|
-
Run only related tests
|
|
4
|
-
|
|
5
|
-
# description
|
|
6
|
-
|
|
7
|
-
Calculates the tests needed to be ran based on the changed metadata given using the Salesforce Dependency API
|
|
8
|
-
|
|
9
|
-
# examples
|
|
10
|
-
|
|
11
|
-
testCmd=$(sf delta test-classes --target-org matt@never.io.dev)
|
|
12
|
-
sf project deploy validate ${testCmd}
|
|
13
|
-
|
|
14
|
-
# flags.target-org.summary
|
|
15
|
-
|
|
16
|
-
The org you want to check the dependencies against.
|
|
17
|
-
|
|
18
|
-
# flags.package-path.summary
|
|
19
|
-
|
|
20
|
-
Path to the package.xml that will be deployed.
|
|
21
|
-
|
|
22
|
-
# flags.always-run-test.summary
|
|
23
|
-
|
|
24
|
-
A test class to run when no tests need to be ran.
|
|
1
|
+
# summary
|
|
2
|
+
|
|
3
|
+
Run only related tests
|
|
4
|
+
|
|
5
|
+
# description
|
|
6
|
+
|
|
7
|
+
Calculates the tests needed to be ran based on the changed metadata given using the Salesforce Dependency API
|
|
8
|
+
|
|
9
|
+
# examples
|
|
10
|
+
|
|
11
|
+
testCmd=$(sf delta test-classes --target-org matt@never.io.dev)
|
|
12
|
+
sf project deploy validate ${testCmd}
|
|
13
|
+
|
|
14
|
+
# flags.target-org.summary
|
|
15
|
+
|
|
16
|
+
The org you want to check the dependencies against.
|
|
17
|
+
|
|
18
|
+
# flags.package-path.summary
|
|
19
|
+
|
|
20
|
+
Path to the package.xml that will be deployed.
|
|
21
|
+
|
|
22
|
+
# flags.always-run-test.summary
|
|
23
|
+
|
|
24
|
+
A test class to run when no tests need to be ran.
|
|
25
|
+
|
|
26
|
+
# flags.include-all-flows.summary
|
|
27
|
+
|
|
28
|
+
When enabled, if any Flow is changed, include all Flows that require test coverage based on their trigger type or process type. This ensures proper test coverage validation since Salesforce checks coverage for all such Flows during deployment, not just the changed ones. Use --no-include-all-flows to disable.
|
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.0.
|
|
2
|
+
"version": "0.0.26",
|
|
3
3
|
"commands": {
|
|
4
4
|
"delta:test-classes": {
|
|
5
5
|
"id": "delta:test-classes",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"pluginType": "core",
|
|
12
12
|
"aliases": [],
|
|
13
13
|
"examples": [
|
|
14
|
-
"testCmd=$(sf delta test-classes --target-org matt@never.io.dev)\nsf project deploy validate ${testCmd}"
|
|
14
|
+
"testCmd=$(sf delta test-classes --target-org matt@never.io.dev)\r\nsf project deploy validate ${testCmd}"
|
|
15
15
|
],
|
|
16
16
|
"flags": {
|
|
17
17
|
"json": {
|
|
@@ -42,6 +42,12 @@
|
|
|
42
42
|
"type": "option",
|
|
43
43
|
"summary": "A test class to run when no tests need to be ran.",
|
|
44
44
|
"multiple": true
|
|
45
|
+
},
|
|
46
|
+
"include-all-flows": {
|
|
47
|
+
"name": "include-all-flows",
|
|
48
|
+
"type": "boolean",
|
|
49
|
+
"summary": "When enabled, if any Flow is changed, include all Flows that require test coverage based on their trigger type or process type. This ensures proper test coverage validation since Salesforce checks coverage for all such Flows during deployment, not just the changed ones. Use --no-include-all-flows to disable.",
|
|
50
|
+
"allowNo": true
|
|
45
51
|
}
|
|
46
52
|
},
|
|
47
53
|
"args": {},
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sf-delta-tests",
|
|
3
3
|
"description": "Calculate dependencies and scope to relevant tests",
|
|
4
|
-
"version": "0.0
|
|
4
|
+
"version": "0.1.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@oclif/core": "^2.11.8",
|
|
7
7
|
"@salesforce/core": "^5.2.0",
|
|
8
8
|
"@salesforce/kit": "^3.0.8",
|
|
9
9
|
"@salesforce/sf-plugins-core": "^3.1.14",
|
|
10
10
|
"@salesforce/source-deploy-retrieve": "^9.7.8",
|
|
11
|
-
"fast-xml-parser": "^
|
|
12
|
-
"glob": "^
|
|
11
|
+
"fast-xml-parser": "^5.3.3",
|
|
12
|
+
"glob": "^11.1.0",
|
|
13
13
|
"lodash": "^4.17.21",
|
|
14
14
|
"tslib": "^2"
|
|
15
15
|
},
|
|
@@ -152,7 +152,7 @@
|
|
|
152
152
|
},
|
|
153
153
|
"author": "matthew-gladman",
|
|
154
154
|
"volta": {
|
|
155
|
-
"node": "
|
|
155
|
+
"node": "20.19.6",
|
|
156
156
|
"yarn": "1.22.19"
|
|
157
157
|
}
|
|
158
158
|
}
|