sf-flow-coverage 0.2.0 → 0.4.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/CHANGELOG.md +24 -0
- package/README.md +142 -17
- package/lib/commands/flowcov/gate.d.ts +1 -0
- package/lib/commands/flowcov/gate.js +15 -2
- package/lib/commands/flowcov/gate.js.map +1 -1
- package/lib/commands/flowcov/readiness.js +25 -3
- package/lib/commands/flowcov/readiness.js.map +1 -1
- package/lib/commands/flowcov/transform.d.ts +15 -0
- package/lib/commands/flowcov/transform.js +78 -0
- package/lib/commands/flowcov/transform.js.map +1 -0
- package/lib/core/apexTemplate.d.ts +16 -1
- package/lib/core/apexTemplate.js +462 -104
- package/lib/core/apexTemplate.js.map +1 -1
- package/lib/core/conditions.d.ts +107 -0
- package/lib/core/conditions.js +481 -0
- package/lib/core/conditions.js.map +1 -0
- package/lib/core/coverageCheck.d.ts +8 -0
- package/lib/core/coverageCheck.js +12 -0
- package/lib/core/coverageCheck.js.map +1 -0
- package/lib/core/coverageFormats.d.ts +7 -0
- package/lib/core/coverageFormats.js +77 -0
- package/lib/core/coverageFormats.js.map +1 -0
- package/lib/core/criteria.d.ts +40 -0
- package/lib/core/criteria.js +262 -0
- package/lib/core/criteria.js.map +1 -0
- package/lib/core/elementCoverage.d.ts +9 -0
- package/lib/core/elementCoverage.js +27 -0
- package/lib/core/elementCoverage.js.map +1 -0
- package/lib/core/flowElementLines.d.ts +13 -0
- package/lib/core/flowElementLines.js +44 -0
- package/lib/core/flowElementLines.js.map +1 -0
- package/lib/core/flowFingerprint.d.ts +37 -0
- package/lib/core/flowFingerprint.js +142 -0
- package/lib/core/flowFingerprint.js.map +1 -0
- package/lib/core/flowGraph.d.ts +144 -0
- package/lib/core/flowGraph.js +279 -0
- package/lib/core/flowGraph.js.map +1 -0
- package/lib/core/flowSettings.d.ts +16 -0
- package/lib/core/flowSettings.js +49 -0
- package/lib/core/flowSettings.js.map +1 -0
- package/lib/core/flowTypes.d.ts +6 -0
- package/lib/core/flowTypes.js +17 -0
- package/lib/core/flowTypes.js.map +1 -1
- package/lib/core/flowValues.d.ts +14 -0
- package/lib/core/flowValues.js +43 -0
- package/lib/core/flowValues.js.map +1 -0
- package/lib/core/flowXml.d.ts +1 -1
- package/lib/core/flowXml.js +6 -39
- package/lib/core/flowXml.js.map +1 -1
- package/lib/core/formula.d.ts +48 -0
- package/lib/core/formula.js +227 -0
- package/lib/core/formula.js.map +1 -0
- package/lib/core/gate.d.ts +10 -1
- package/lib/core/gate.js +64 -7
- package/lib/core/gate.js.map +1 -1
- package/lib/core/orgCoverageSource.d.ts +9 -0
- package/lib/core/orgCoverageSource.js +68 -12
- package/lib/core/orgCoverageSource.js.map +1 -1
- package/lib/core/readiness.d.ts +5 -0
- package/lib/core/readiness.js +24 -10
- package/lib/core/readiness.js.map +1 -1
- package/lib/core/requiredFields.d.ts +53 -3
- package/lib/core/requiredFields.js +158 -10
- package/lib/core/requiredFields.js.map +1 -1
- package/lib/core/scaffold.js +50 -4
- package/lib/core/scaffold.js.map +1 -1
- package/lib/core/toolingQuery.d.ts +5 -0
- package/lib/core/toolingQuery.js +9 -1
- package/lib/core/toolingQuery.js.map +1 -1
- package/lib/core/transform.d.ts +36 -0
- package/lib/core/transform.js +62 -0
- package/lib/core/transform.js.map +1 -0
- package/lib/core/types.d.ts +79 -1
- package/lib/index.d.ts +6 -1
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/messages/flowcov.gate.md +19 -1
- package/messages/flowcov.readiness.md +4 -2
- package/messages/flowcov.scaffold.md +5 -1
- package/messages/flowcov.transform.md +33 -0
- package/oclif.manifest.json +113 -4
- package/package.json +1 -1
package/lib/core/toolingQuery.js
CHANGED
|
@@ -6,11 +6,19 @@ export function toolingQuery(connection) {
|
|
|
6
6
|
return result.records;
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
|
+
/** Adapts an org connection to a data API query, fetching every page. */
|
|
10
|
+
export function dataQuery(connection) {
|
|
11
|
+
return async (soql) => (await connection.query(soql, { autoFetch: true, maxFetch: MAX_FETCH })).records;
|
|
12
|
+
}
|
|
13
|
+
/** Adapts an org connection to the MetadataRead used to read org settings. */
|
|
14
|
+
export function metadataRead(connection) {
|
|
15
|
+
return async (type, fullName) => connection.metadata.read(type, fullName);
|
|
16
|
+
}
|
|
9
17
|
/** Adapts an org connection to the DescribeObject used by scaffolding to fill required fields. */
|
|
10
18
|
export function describeObject(connection) {
|
|
11
19
|
return async (objectName) => {
|
|
12
20
|
const result = await connection.describe(objectName);
|
|
13
|
-
return result.fields;
|
|
21
|
+
return { fields: result.fields, recordTypeInfos: result.recordTypeInfos };
|
|
14
22
|
};
|
|
15
23
|
}
|
|
16
24
|
//# sourceMappingURL=toolingQuery.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolingQuery.js","sourceRoot":"","sources":["../../src/core/toolingQuery.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"toolingQuery.js","sourceRoot":"","sources":["../../src/core/toolingQuery.ts"],"names":[],"mappings":"AAMA,MAAM,SAAS,GAAG,SAAS,CAAC;AAE5B,mGAAmG;AACnG,MAAM,UAAU,YAAY,CAAC,UAAuC;IAClE,OAAO,KAAK,EAAqC,IAAY,EAAgB,EAAE;QAC7E,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,KAAK,CAAI,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC;QACjG,OAAO,MAAM,CAAC,OAAO,CAAC;IACxB,CAAC,CAAC;AACJ,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,SAAS,CAAC,UAAqC;IAC7D,OAAO,KAAK,EAAqC,IAAY,EAAgB,EAAE,CAC7E,CAAC,MAAM,UAAU,CAAC,KAAK,CAAI,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;AACxF,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,YAAY,CAAC,UAAwC;IACnE,OAAO,KAAK,EAAE,IAAY,EAAE,QAAgB,EAAoB,EAAE,CAChE,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAqD,EAAE,QAAQ,CAAC,CAAC;AAC9F,CAAC;AAED,kGAAkG;AAClG,MAAM,UAAU,cAAc,CAAC,UAAwC;IACrE,OAAO,KAAK,EAAE,UAAkB,EAA2B,EAAE;QAC3D,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QACrD,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,MAAoC,EAAE,eAAe,EAAE,MAAM,CAAC,eAAe,EAAE,CAAC;IAC1G,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { CoverageSource } from './types.js';
|
|
2
|
+
/** One executable element of a Flow as a line in its source file. */
|
|
3
|
+
export type FlowCoverageLine = {
|
|
4
|
+
line: number;
|
|
5
|
+
covered: boolean;
|
|
6
|
+
element: string;
|
|
7
|
+
type: string;
|
|
8
|
+
};
|
|
9
|
+
/** Element coverage of one Flow, mapped onto its source file. */
|
|
10
|
+
export type FlowFileCoverage = {
|
|
11
|
+
flowName: string;
|
|
12
|
+
/** Source file path relative to the project directory, with `/` separators. */
|
|
13
|
+
path: string;
|
|
14
|
+
lines: FlowCoverageLine[];
|
|
15
|
+
};
|
|
16
|
+
export type FlowFileCoverageReport = {
|
|
17
|
+
files: FlowFileCoverage[];
|
|
18
|
+
/** Active Flows left out, and why. */
|
|
19
|
+
skipped: Array<{
|
|
20
|
+
flowName: string;
|
|
21
|
+
reason: string;
|
|
22
|
+
}>;
|
|
23
|
+
/** Flows whose source file may not match the version the org covered. */
|
|
24
|
+
warnings: string[];
|
|
25
|
+
};
|
|
26
|
+
export type FlowFileCoverageOptions = {
|
|
27
|
+
source: CoverageSource;
|
|
28
|
+
/** Project root: searched for Flow files; output paths are relative to it. */
|
|
29
|
+
projectDir: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Maps the org's element coverage onto the project's Flow files: each executable element is a
|
|
33
|
+
* line (the line of its `<name>`), covered when any Apex test ran it. Covers every active Flow
|
|
34
|
+
* that counts toward deploy-as-active and has a source file in the project.
|
|
35
|
+
*/
|
|
36
|
+
export declare function buildFlowFileCoverage(options: FlowFileCoverageOptions): Promise<FlowFileCoverageReport>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { relative, sep } from 'node:path';
|
|
3
|
+
import { missingCoverageWarning } from './coverageCheck.js';
|
|
4
|
+
import { flowElementLines } from './flowElementLines.js';
|
|
5
|
+
import { findFlowFiles } from './projectFiles.js';
|
|
6
|
+
/**
|
|
7
|
+
* Maps the org's element coverage onto the project's Flow files: each executable element is a
|
|
8
|
+
* line (the line of its `<name>`), covered when any Apex test ran it. Covers every active Flow
|
|
9
|
+
* that counts toward deploy-as-active and has a source file in the project.
|
|
10
|
+
*/
|
|
11
|
+
export async function buildFlowFileCoverage(options) {
|
|
12
|
+
const flows = await options.source.listActiveCountedFlows();
|
|
13
|
+
const flowFiles = await findFlowFiles(options.projectDir);
|
|
14
|
+
const report = { files: [], skipped: [], warnings: [] };
|
|
15
|
+
for (const flow of [...flows].sort((a, b) => a.flowName.localeCompare(b.flowName))) {
|
|
16
|
+
const file = flowFiles.get(flow.flowName);
|
|
17
|
+
if (!file) {
|
|
18
|
+
report.skipped.push({ flowName: flow.flowName, reason: 'No source file in the project.' });
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
if (flow.covered && !flow.coveredElementNames) {
|
|
22
|
+
report.skipped.push({ flowName: flow.flowName, reason: 'The org did not report which elements tests ran.' });
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
const path = relative(options.projectDir, file).split(sep).join('/');
|
|
26
|
+
const elements = flowElementLines(await readFile(file, 'utf8'));
|
|
27
|
+
if (elements.length === 0) {
|
|
28
|
+
report.skipped.push({ flowName: flow.flowName, reason: 'The source file has no elements.' });
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const covered = new Set((flow.coveredElementNames ?? []).map((name) => name.toLowerCase()));
|
|
32
|
+
const local = new Set(elements.map((e) => e.name.toLowerCase()));
|
|
33
|
+
// Salesforce counts elements only for versions some test ran, so uncovered Flows can't be compared.
|
|
34
|
+
const version = `version ${flow.versionNumber ?? '?'} in the org`;
|
|
35
|
+
const missing = [...covered].filter((name) => !local.has(name));
|
|
36
|
+
let mismatch;
|
|
37
|
+
if (flow.covered && elements.length !== flow.elementsTotal) {
|
|
38
|
+
mismatch = `${path} has ${elements.length} elements, but ${version} has ${flow.elementsTotal}`;
|
|
39
|
+
}
|
|
40
|
+
else if (missing.length > 0) {
|
|
41
|
+
mismatch = `tests ran elements of ${version} that ${path} doesn't have (${missing.join(', ')})`;
|
|
42
|
+
}
|
|
43
|
+
if (mismatch) {
|
|
44
|
+
report.warnings.push(`${flow.flowName}: ${mismatch}. Its line coverage may be off; retrieve or deploy the Flow so they match.`);
|
|
45
|
+
}
|
|
46
|
+
report.files.push({
|
|
47
|
+
flowName: flow.flowName,
|
|
48
|
+
path,
|
|
49
|
+
lines: elements.map((e) => ({
|
|
50
|
+
line: e.line,
|
|
51
|
+
covered: covered.has(e.name.toLowerCase()),
|
|
52
|
+
element: e.name,
|
|
53
|
+
type: e.type,
|
|
54
|
+
})),
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
const warning = await missingCoverageWarning(options.source, report.files.length > 0 && flows.every((flow) => !flow.covered));
|
|
58
|
+
if (warning)
|
|
59
|
+
report.warnings.unshift(warning);
|
|
60
|
+
return report;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=transform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform.js","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import type { FlowFingerprint } from './flowFingerprint.js';
|
|
2
|
+
import type { FlowGraph } from './flowGraph.js';
|
|
3
|
+
/** A Flow element no Apex test ran. */
|
|
4
|
+
export type UncoveredElement = {
|
|
5
|
+
/** Element API name, as in the Flow's metadata. */
|
|
6
|
+
name: string;
|
|
7
|
+
/** Element type, such as `decision` or `recordUpdate`. */
|
|
8
|
+
type: string;
|
|
9
|
+
};
|
|
1
10
|
/** One Apex test method that ran a Flow version. */
|
|
2
11
|
export type FlowTestRef = {
|
|
3
12
|
className: string;
|
|
@@ -18,7 +27,22 @@ export type FlowCoverage = {
|
|
|
18
27
|
/** Elements covered across all tests, 0-100. */
|
|
19
28
|
elementCoveragePercent: number;
|
|
20
29
|
tests: FlowTestRef[];
|
|
30
|
+
/**
|
|
31
|
+
* Lowercased names of the elements any test ran (FlowElementTestCoverage reports them in lower
|
|
32
|
+
* case). Undefined when element coverage can't be read.
|
|
33
|
+
*/
|
|
34
|
+
coveredElementNames?: string[];
|
|
35
|
+
/**
|
|
36
|
+
* How this version relates to the Flow's other versions, when known (set by `getFlowCoverage`):
|
|
37
|
+
* - `current`: it is the active version and the latest one.
|
|
38
|
+
* - `noActiveVersion`: no version is active; this is the latest, inactive version.
|
|
39
|
+
* - `newerInactiveVersion`: it is active, but a newer inactive version exists.
|
|
40
|
+
*/
|
|
41
|
+
versionState?: FlowVersionState;
|
|
42
|
+
/** Version number of the Flow's latest version, when it differs from `versionNumber`. */
|
|
43
|
+
latestVersionNumber?: number;
|
|
21
44
|
};
|
|
45
|
+
export type FlowVersionState = 'current' | 'noActiveVersion' | 'newerInactiveVersion';
|
|
22
46
|
/**
|
|
23
47
|
* Where Flow coverage comes from. Today the only implementation reads FlowTestCoverage
|
|
24
48
|
* through the Tooling API; this seam exists so Flow Builder Test Mode coverage can be
|
|
@@ -27,8 +51,21 @@ export type FlowCoverage = {
|
|
|
27
51
|
export type CoverageSource = {
|
|
28
52
|
/** Every active Flow version that counts toward the deploy-as-active coverage requirement. */
|
|
29
53
|
listActiveCountedFlows(): Promise<FlowCoverage[]>;
|
|
30
|
-
/**
|
|
54
|
+
/**
|
|
55
|
+
* Coverage for the named Flows (active version, else latest), with `versionState` set.
|
|
56
|
+
* Names missing from the org are omitted.
|
|
57
|
+
*/
|
|
31
58
|
getFlowCoverage(flowNames: string[]): Promise<FlowCoverage[]>;
|
|
59
|
+
/**
|
|
60
|
+
* Fingerprint of a Flow version's content, to compare with source. Undefined when the
|
|
61
|
+
* source can't read the version's content.
|
|
62
|
+
*/
|
|
63
|
+
getFlowFingerprint?(flowVersionId: string): Promise<FlowFingerprint | undefined>;
|
|
64
|
+
/**
|
|
65
|
+
* Whether the org has any Flow coverage at all, for any Flow version. False usually means
|
|
66
|
+
* Apex tests ran without code coverage on.
|
|
67
|
+
*/
|
|
68
|
+
hasAnyFlowCoverage?(): Promise<boolean>;
|
|
32
69
|
};
|
|
33
70
|
/** Runs a Tooling API SOQL query and returns every record (all pages). */
|
|
34
71
|
export type ToolingQuery = <T extends Record<string, unknown>>(soql: string) => Promise<T[]>;
|
|
@@ -64,6 +101,8 @@ export type FlowMetadata = {
|
|
|
64
101
|
filters: FlowFilter[];
|
|
65
102
|
filterLogic?: string;
|
|
66
103
|
filterFormula?: string;
|
|
104
|
+
/** The Flow's elements, for working out what a test can assert. */
|
|
105
|
+
graph?: FlowGraph;
|
|
67
106
|
variables: FlowVariable[];
|
|
68
107
|
};
|
|
69
108
|
export type ReadinessFlow = {
|
|
@@ -75,6 +114,8 @@ export type ReadinessFlow = {
|
|
|
75
114
|
tests: FlowTestRef[];
|
|
76
115
|
/** Commits that touched the Flow's source file, when the project is a git repo. */
|
|
77
116
|
changes?: number;
|
|
117
|
+
/** Elements no test ran, for Flows some test runs. Undefined when they can't be read. */
|
|
118
|
+
uncoveredElements?: UncoveredElement[];
|
|
78
119
|
};
|
|
79
120
|
export type ReadinessResult = {
|
|
80
121
|
threshold: number;
|
|
@@ -85,6 +126,14 @@ export type ReadinessResult = {
|
|
|
85
126
|
ready: boolean;
|
|
86
127
|
/** Additional Flows that need a test to reach the threshold. */
|
|
87
128
|
flowsNeeded: number;
|
|
129
|
+
/** Active Process Builder processes among the counted Flows. Salesforce no longer supports Process Builder. */
|
|
130
|
+
processBuilderProcesses: number;
|
|
131
|
+
/** Whether "Deploy processes and flows as active" is on. Undefined when it could not be read. */
|
|
132
|
+
deployAsActive?: boolean;
|
|
133
|
+
/** Whether the org is a sandbox or scratch org, where the setting doesn't apply. Undefined when unknown. */
|
|
134
|
+
isSandbox?: boolean;
|
|
135
|
+
/** Problems with the report as a whole, such as no Flow coverage recorded in the org. */
|
|
136
|
+
warnings: string[];
|
|
88
137
|
/** Uncovered first (most-changed first), then covered. */
|
|
89
138
|
flows: ReadinessFlow[];
|
|
90
139
|
};
|
|
@@ -97,11 +146,40 @@ export type GateFlowResult = {
|
|
|
97
146
|
versionNumber?: number;
|
|
98
147
|
elementCoveragePercent?: number;
|
|
99
148
|
tests: FlowTestRef[];
|
|
149
|
+
/** Problems that don't change `status`, such as an org version that differs from source. */
|
|
150
|
+
warnings?: string[];
|
|
151
|
+
/** Elements no test ran, for Flows some test runs. Undefined when they can't be read. */
|
|
152
|
+
uncoveredElements?: UncoveredElement[];
|
|
100
153
|
};
|
|
154
|
+
/** What the gate does when the org's Flow content differs from source. */
|
|
155
|
+
export type ContentCheck = 'warn' | 'fail' | 'off';
|
|
101
156
|
export type GateResult = {
|
|
102
157
|
passed: boolean;
|
|
103
158
|
minElementCoverage: number;
|
|
104
159
|
flows: GateFlowResult[];
|
|
160
|
+
/** Problems with the run as a whole, such as no Flow coverage recorded in the org. */
|
|
161
|
+
warnings: string[];
|
|
162
|
+
};
|
|
163
|
+
export type TransformResult = {
|
|
164
|
+
/** Each coverage report written. */
|
|
165
|
+
files: Array<{
|
|
166
|
+
format: string;
|
|
167
|
+
path: string;
|
|
168
|
+
}>;
|
|
169
|
+
/** Flows in the reports, with their element counts. */
|
|
170
|
+
flows: Array<{
|
|
171
|
+
flowName: string;
|
|
172
|
+
path: string;
|
|
173
|
+
elementsCovered: number;
|
|
174
|
+
elementsTotal: number;
|
|
175
|
+
}>;
|
|
176
|
+
/** Active Flows left out of the reports, and why. */
|
|
177
|
+
skipped: Array<{
|
|
178
|
+
flowName: string;
|
|
179
|
+
reason: string;
|
|
180
|
+
}>;
|
|
181
|
+
/** Flows whose source file may not match the version the org covered. */
|
|
182
|
+
warnings: string[];
|
|
105
183
|
};
|
|
106
184
|
export type ScaffoldedTest = {
|
|
107
185
|
flowName: string;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export { apexClassMetaXml, apexTestClassName, generateApexTest } from './core/apexTemplate.js';
|
|
2
|
+
export type { CoverageFormat } from './core/coverageFormats.js';
|
|
3
|
+
export { COVERAGE_FORMATS, formatCoverage } from './core/coverageFormats.js';
|
|
4
|
+
export type { DataQuery, MetadataRead } from './core/flowSettings.js';
|
|
2
5
|
export { COUNTED_PROCESS_TYPES, DEFAULT_THRESHOLD, isCountedProcessType } from './core/flowTypes.js';
|
|
3
6
|
export { parseFlowXml } from './core/flowXml.js';
|
|
4
7
|
export type { GateCandidate, GateOptions } from './core/gate.js';
|
|
@@ -10,5 +13,7 @@ export type { DescribeField, DescribeObject, RequiredFieldMap } from './core/req
|
|
|
10
13
|
export { requiredFieldValues } from './core/requiredFields.js';
|
|
11
14
|
export type { ScaffoldOptions } from './core/scaffold.js';
|
|
12
15
|
export { scaffoldTests } from './core/scaffold.js';
|
|
13
|
-
export { describeObject, toolingQuery } from './core/toolingQuery.js';
|
|
16
|
+
export { dataQuery, describeObject, metadataRead, toolingQuery } from './core/toolingQuery.js';
|
|
17
|
+
export type { FlowCoverageLine, FlowFileCoverage, FlowFileCoverageOptions, FlowFileCoverageReport, } from './core/transform.js';
|
|
18
|
+
export { buildFlowFileCoverage } from './core/transform.js';
|
|
14
19
|
export type * from './core/types.js';
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { apexClassMetaXml, apexTestClassName, generateApexTest } from './core/apexTemplate.js';
|
|
2
|
+
export { COVERAGE_FORMATS, formatCoverage } from './core/coverageFormats.js';
|
|
2
3
|
export { COUNTED_PROCESS_TYPES, DEFAULT_THRESHOLD, isCountedProcessType } from './core/flowTypes.js';
|
|
3
4
|
export { parseFlowXml } from './core/flowXml.js';
|
|
4
5
|
export { collectChangedFlows, evaluateGate } from './core/gate.js';
|
|
@@ -6,5 +7,6 @@ export { OrgCoverageSource } from './core/orgCoverageSource.js';
|
|
|
6
7
|
export { buildReadinessReport } from './core/readiness.js';
|
|
7
8
|
export { requiredFieldValues } from './core/requiredFields.js';
|
|
8
9
|
export { scaffoldTests } from './core/scaffold.js';
|
|
9
|
-
export { describeObject, toolingQuery } from './core/toolingQuery.js';
|
|
10
|
+
export { dataQuery, describeObject, metadataRead, toolingQuery } from './core/toolingQuery.js';
|
|
11
|
+
export { buildFlowFileCoverage } from './core/transform.js';
|
|
10
12
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/F,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE7E,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACrG,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAO/F,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC"}
|
package/messages/flowcov.gate.md
CHANGED
|
@@ -6,7 +6,13 @@ Require Apex test coverage for every Flow a pull request changes.
|
|
|
6
6
|
|
|
7
7
|
Salesforce only checks that the org-wide total stays at or above 75%, so a single Flow with no tests can still be deployed as active. This gate checks each changed Flow on its own: every active autolaunched Flow or process changed between --from and --to must be run by at least one Apex test, and optionally reach a minimum element coverage.
|
|
8
8
|
|
|
9
|
-
Coverage is read from FlowTestCoverage in the target org. Deploy the branch to the target org and run Apex tests there with `sf apex run test --code-coverage` before running the gate. Without `--code-coverage`, Salesforce records no Flow coverage. Flows that don't count toward deploy-as-active (screen Flows, inactive Flows) are skipped.
|
|
9
|
+
Coverage is read from FlowTestCoverage in the target org. Deploy the branch to the target org and run Apex tests there with `sf apex run test --code-coverage` before running the gate. Without `--code-coverage`, Salesforce records no Flow coverage. When no Flow in the org has any coverage recorded, the command warns that the tests most likely ran without `--code-coverage`. Flows that don't count toward deploy-as-active (screen Flows, inactive Flows) are skipped.
|
|
10
|
+
|
|
11
|
+
The gate also fails a Flow when the org has no active version of it, or when its active version is older than its latest version. Both usually mean the branch was deployed inactive, so the org's coverage doesn't belong to the version in the pull request.
|
|
12
|
+
|
|
13
|
+
With --from, the gate also compares each changed Flow at --to with the org's version: process type, start trigger and entry criteria, and the names of its elements and resources. A difference usually means the branch wasn't deployed to the org. By default this is a warning; use --content-check to fail instead, or to skip the comparison. The comparison doesn't look inside elements, so it can miss a change that only edits an existing element.
|
|
14
|
+
|
|
15
|
+
For a Flow that tests run only in part, the --json output lists the elements no test runs, and a Flow that fails --min-element-coverage names them in its reason.
|
|
10
16
|
|
|
11
17
|
Exits with code 1 when any Flow fails.
|
|
12
18
|
|
|
@@ -20,6 +26,10 @@ Exits with code 1 when any Flow fails.
|
|
|
20
26
|
|
|
21
27
|
<%= config.bin %> <%= command.id %> --target-org ci-sandbox --from origin/main --min-element-coverage 60
|
|
22
28
|
|
|
29
|
+
- Fail when the org runs a different version of a changed Flow than the branch:
|
|
30
|
+
|
|
31
|
+
<%= config.bin %> <%= command.id %> --target-org ci-sandbox --from origin/main --content-check fail
|
|
32
|
+
|
|
23
33
|
- Check named Flows without git:
|
|
24
34
|
|
|
25
35
|
<%= config.bin %> <%= command.id %> --target-org ci-sandbox --flow Account_After_Save --flow Close_Cases
|
|
@@ -44,6 +54,14 @@ Git repository to read changed Flows from.
|
|
|
44
54
|
|
|
45
55
|
Minimum percentage of each Flow's elements that tests must run.
|
|
46
56
|
|
|
57
|
+
# flags.content-check.summary
|
|
58
|
+
|
|
59
|
+
What to do when a changed Flow's content differs from the org's version.
|
|
60
|
+
|
|
61
|
+
# flags.content-check.description
|
|
62
|
+
|
|
63
|
+
"warn" prints a warning, "fail" fails a Flow that would otherwise pass, and "off" skips the comparison (and its one Tooling API query per Flow). Only applies with --from.
|
|
64
|
+
|
|
47
65
|
# error.noInput
|
|
48
66
|
|
|
49
67
|
Provide --from to check changed Flows, or --flow to check named Flows.
|
|
@@ -4,9 +4,11 @@ Report how close the org is to the coverage needed to deploy Flows as active.
|
|
|
4
4
|
|
|
5
5
|
# description
|
|
6
6
|
|
|
7
|
-
Salesforce requires 75% of active autolaunched Flows and processes to be run by at least one Apex test before you can turn on "Deploy processes and flows as active". This command reads FlowTestCoverage from the target org, reports the org-wide percentage against the threshold, and lists the uncovered Flows (ranked by how often they change in git) and the Apex tests that
|
|
7
|
+
Salesforce requires 75% of active autolaunched Flows and processes to be run by at least one Apex test before you can turn on "Deploy processes and flows as active". This command reads FlowTestCoverage from the target org, reports the org-wide percentage against the threshold, and lists the uncovered Flows (ranked by how often they change in git) and, for each covered Flow, the Apex tests that run it and the elements no test runs yet. Listing those elements takes one Tooling API query per partly covered Flow. Process Builder processes are labeled and counted, with a suggestion to migrate them to Flows, since Salesforce no longer supports Process Builder.
|
|
8
8
|
|
|
9
|
-
FlowTestCoverage is filled in when Apex tests run in the org. Run your Apex tests first with coverage turned on (for example, `sf apex run test --test-level RunLocalTests --code-coverage --wait 60`) so the report is current. Without `--code-coverage`, Salesforce records no Flow coverage.
|
|
9
|
+
FlowTestCoverage is filled in when Apex tests run in the org. Run your Apex tests first with coverage turned on (for example, `sf apex run test --test-level RunLocalTests --code-coverage --wait 60`) so the report is current. Without `--code-coverage`, Salesforce records no Flow coverage. When no Flow in the org has any coverage recorded, the command warns that the tests most likely ran without `--code-coverage`.
|
|
10
|
+
|
|
11
|
+
The report also says whether "Deploy processes and flows as active" is already on, and what that means: turn it on once the org is ready, or keep coverage up so deployments of active Flows keep working. The setting only affects production; in a sandbox or scratch org the report says so.
|
|
10
12
|
|
|
11
13
|
# examples
|
|
12
14
|
|
|
@@ -4,7 +4,11 @@ Generate starter Apex tests for Flows.
|
|
|
4
4
|
|
|
5
5
|
# description
|
|
6
6
|
|
|
7
|
-
Reads each Flow's metadata file from the project and writes an Apex test class named `<Flow>_FlowTest` that runs it: record-triggered Flows get a record built from the trigger object and entry criteria, autolaunched Flows are started with Flow.Interview and their input variables, and platform event Flows publish the event. When a target org is available (--target-org or a default org), the command describes each object the test creates and fills in its required fields
|
|
7
|
+
Reads each Flow's metadata file from the project and writes an Apex test class named `<Flow>_FlowTest` that runs it: record-triggered Flows get a record built from the trigger object and entry criteria, autolaunched Flows are started with Flow.Interview and their input variables, and platform event Flows publish the event. When a target org is available (--target-org or a default org), the command describes each object the test creates and fills in its required fields, the fields the entry criteria need, and parent records (and their parents) for required lookups.
|
|
8
|
+
|
|
9
|
+
Entry criteria are read as one condition, whether they are filters (with AND, OR, or custom logic) or a formula. The command meets one branch of an OR, and handles comparisons with literals, other fields, `$User.Id`, and `TODAY()`; `$Record__Prior` values in update tests; and fields on related records, which it sets on the parent record it inserts.
|
|
10
|
+
|
|
11
|
+
For record-triggered Flows, the command follows the Flow's elements for the record the test creates, deciding each decision the record settles (including formula resources, and lookups on data the test doesn't create, which find nothing in an Apex test). It asserts the fields the Flow is certain to set and the records it is certain to create. When the Flow is certain to stop the save with a custom error, the test expects that error, and a second test sets the fields that avoid it. For autolaunched Flows, it asserts output variables the Flow is certain to set. What the Flow does only on a decision outcome the command can't predict gets commented-out assertions. The generated tests have TODOs for anything the command can't fill in.
|
|
8
12
|
|
|
9
13
|
Only Apex tests count toward deploying Flows as active, so this command generates Apex, not Flow Builder tests.
|
|
10
14
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# summary
|
|
2
|
+
|
|
3
|
+
Write Flow element coverage as SonarQube, Cobertura, or lcov coverage reports.
|
|
4
|
+
|
|
5
|
+
# description
|
|
6
|
+
|
|
7
|
+
Reads Flow coverage from the target org and maps it onto the project's Flow metadata files, so Flow coverage shows up next to Apex coverage in tools such as SonarQube, GitLab, Azure DevOps, or Codecov. Each executable element of a Flow (every element except the start element and resources such as variables and formulas) becomes one line: the line of its `<name>` in the `.flow-meta.xml` file, covered when any Apex test ran the element. A Flow's line coverage therefore equals its element coverage.
|
|
8
|
+
|
|
9
|
+
Covers every active Flow and process that counts toward "Deploy processes and flows as active" and has a source file in the project. Paths in the reports are relative to --project-dir; run the command from the root your coverage tool expects. For SonarQube, the Flow files must be indexed (for example, include `**/*.flow-meta.xml` in `sonar.inclusions`) for their coverage to be imported.
|
|
10
|
+
|
|
11
|
+
Coverage is read from FlowTestCoverage, which Salesforce fills in when Apex tests run in the org with coverage on (`sf apex run test --code-coverage`). Without `--code-coverage`, and in check-only deployments, Salesforce records no Flow coverage. When no Flow in the org has any coverage recorded, the command warns that the tests most likely ran without `--code-coverage`. When a Flow file's elements don't match the version the org covered, the command warns that its line coverage may be off.
|
|
12
|
+
|
|
13
|
+
# examples
|
|
14
|
+
|
|
15
|
+
- Write a SonarQube generic coverage report to the coverage folder:
|
|
16
|
+
|
|
17
|
+
<%= config.bin %> <%= command.id %> --target-org ci-sandbox --format sonar
|
|
18
|
+
|
|
19
|
+
- Write Cobertura and lcov reports to a folder of your choice:
|
|
20
|
+
|
|
21
|
+
<%= config.bin %> <%= command.id %> --target-org ci-sandbox --format cobertura --format lcov --output-dir reports
|
|
22
|
+
|
|
23
|
+
# flags.format.summary
|
|
24
|
+
|
|
25
|
+
Coverage format to write: sonar (SonarQube generic coverage), cobertura, or lcov.
|
|
26
|
+
|
|
27
|
+
# flags.output-dir.summary
|
|
28
|
+
|
|
29
|
+
Folder to write the coverage reports to.
|
|
30
|
+
|
|
31
|
+
# flags.project-dir.summary
|
|
32
|
+
|
|
33
|
+
Project root with the Flow metadata files. Report paths are relative to it.
|
package/oclif.manifest.json
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
"flowcov:gate": {
|
|
4
4
|
"aliases": [],
|
|
5
5
|
"args": {},
|
|
6
|
-
"description": "Salesforce only checks that the org-wide total stays at or above 75%, so a single Flow with no tests can still be deployed as active. This gate checks each changed Flow on its own: every active autolaunched Flow or process changed between --from and --to must be run by at least one Apex test, and optionally reach a minimum element coverage.\n\nCoverage is read from FlowTestCoverage in the target org. Deploy the branch to the target org and run Apex tests there with `sf apex run test --code-coverage` before running the gate. Without `--code-coverage`, Salesforce records no Flow coverage. Flows that don't count toward deploy-as-active (screen Flows, inactive Flows) are skipped.\n\nExits with code 1 when any Flow fails.",
|
|
6
|
+
"description": "Salesforce only checks that the org-wide total stays at or above 75%, so a single Flow with no tests can still be deployed as active. This gate checks each changed Flow on its own: every active autolaunched Flow or process changed between --from and --to must be run by at least one Apex test, and optionally reach a minimum element coverage.\n\nCoverage is read from FlowTestCoverage in the target org. Deploy the branch to the target org and run Apex tests there with `sf apex run test --code-coverage` before running the gate. Without `--code-coverage`, Salesforce records no Flow coverage. When no Flow in the org has any coverage recorded, the command warns that the tests most likely ran without `--code-coverage`. Flows that don't count toward deploy-as-active (screen Flows, inactive Flows) are skipped.\n\nThe gate also fails a Flow when the org has no active version of it, or when its active version is older than its latest version. Both usually mean the branch was deployed inactive, so the org's coverage doesn't belong to the version in the pull request.\n\nWith --from, the gate also compares each changed Flow at --to with the org's version: process type, start trigger and entry criteria, and the names of its elements and resources. A difference usually means the branch wasn't deployed to the org. By default this is a warning; use --content-check to fail instead, or to skip the comparison. The comparison doesn't look inside elements, so it can miss a change that only edits an existing element.\n\nFor a Flow that tests run only in part, the --json output lists the elements no test runs, and a Flow that fails --min-element-coverage names them in its reason.\n\nExits with code 1 when any Flow fails.",
|
|
7
7
|
"examples": [
|
|
8
8
|
"Check the Flows changed in a pull request:\n<%= config.bin %> <%= command.id %> --target-org ci-sandbox --from origin/main --to HEAD",
|
|
9
9
|
"Also require 60% element coverage per Flow:\n<%= config.bin %> <%= command.id %> --target-org ci-sandbox --from origin/main --min-element-coverage 60",
|
|
10
|
+
"Fail when the org runs a different version of a changed Flow than the branch:\n<%= config.bin %> <%= command.id %> --target-org ci-sandbox --from origin/main --content-check fail",
|
|
10
11
|
"Check named Flows without git:\n<%= config.bin %> <%= command.id %> --target-org ci-sandbox --flow Account_After_Save --flow Close_Cases"
|
|
11
12
|
],
|
|
12
13
|
"flags": {
|
|
@@ -86,6 +87,20 @@
|
|
|
86
87
|
"hasDynamicHelp": false,
|
|
87
88
|
"multiple": false,
|
|
88
89
|
"type": "option"
|
|
90
|
+
},
|
|
91
|
+
"content-check": {
|
|
92
|
+
"description": "\"warn\" prints a warning, \"fail\" fails a Flow that would otherwise pass, and \"off\" skips the comparison (and its one Tooling API query per Flow). Only applies with --from.",
|
|
93
|
+
"name": "content-check",
|
|
94
|
+
"summary": "What to do when a changed Flow's content differs from the org's version.",
|
|
95
|
+
"default": "warn",
|
|
96
|
+
"hasDynamicHelp": false,
|
|
97
|
+
"multiple": false,
|
|
98
|
+
"options": [
|
|
99
|
+
"warn",
|
|
100
|
+
"fail",
|
|
101
|
+
"off"
|
|
102
|
+
],
|
|
103
|
+
"type": "option"
|
|
89
104
|
}
|
|
90
105
|
},
|
|
91
106
|
"hasDynamicHelp": true,
|
|
@@ -113,7 +128,7 @@
|
|
|
113
128
|
"flowcov:readiness": {
|
|
114
129
|
"aliases": [],
|
|
115
130
|
"args": {},
|
|
116
|
-
"description": "Salesforce requires 75% of active autolaunched Flows and processes to be run by at least one Apex test before you can turn on \"Deploy processes and flows as active\". This command reads FlowTestCoverage from the target org, reports the org-wide percentage against the threshold, and lists the uncovered Flows (ranked by how often they change in git) and the Apex tests that
|
|
131
|
+
"description": "Salesforce requires 75% of active autolaunched Flows and processes to be run by at least one Apex test before you can turn on \"Deploy processes and flows as active\". This command reads FlowTestCoverage from the target org, reports the org-wide percentage against the threshold, and lists the uncovered Flows (ranked by how often they change in git) and, for each covered Flow, the Apex tests that run it and the elements no test runs yet. Listing those elements takes one Tooling API query per partly covered Flow. Process Builder processes are labeled and counted, with a suggestion to migrate them to Flows, since Salesforce no longer supports Process Builder.\n\nFlowTestCoverage is filled in when Apex tests run in the org. Run your Apex tests first with coverage turned on (for example, `sf apex run test --test-level RunLocalTests --code-coverage --wait 60`) so the report is current. Without `--code-coverage`, Salesforce records no Flow coverage. When no Flow in the org has any coverage recorded, the command warns that the tests most likely ran without `--code-coverage`.\n\nThe report also says whether \"Deploy processes and flows as active\" is already on, and what that means: turn it on once the org is ready, or keep coverage up so deployments of active Flows keep working. The setting only affects production; in a sandbox or scratch org the report says so.",
|
|
117
132
|
"examples": [
|
|
118
133
|
"Report readiness for the default org:\n<%= config.bin %> <%= command.id %>",
|
|
119
134
|
"Rank uncovered Flows by changes in the last 6 months:\n<%= config.bin %> <%= command.id %> --target-org prod --since \"6 months ago\"",
|
|
@@ -208,7 +223,7 @@
|
|
|
208
223
|
"flowcov:scaffold": {
|
|
209
224
|
"aliases": [],
|
|
210
225
|
"args": {},
|
|
211
|
-
"description": "Reads each Flow's metadata file from the project and writes an Apex test class named `<Flow>_FlowTest` that runs it: record-triggered Flows get a record built from the trigger object and entry criteria, autolaunched Flows are started with Flow.Interview and their input variables, and platform event Flows publish the event. When a target org is available (--target-org or a default org), the command describes each object the test creates and fills in its required fields
|
|
226
|
+
"description": "Reads each Flow's metadata file from the project and writes an Apex test class named `<Flow>_FlowTest` that runs it: record-triggered Flows get a record built from the trigger object and entry criteria, autolaunched Flows are started with Flow.Interview and their input variables, and platform event Flows publish the event. When a target org is available (--target-org or a default org), the command describes each object the test creates and fills in its required fields, the fields the entry criteria need, and parent records (and their parents) for required lookups.\n\nEntry criteria are read as one condition, whether they are filters (with AND, OR, or custom logic) or a formula. The command meets one branch of an OR, and handles comparisons with literals, other fields, `$User.Id`, and `TODAY()`; `$Record__Prior` values in update tests; and fields on related records, which it sets on the parent record it inserts.\n\nFor record-triggered Flows, the command follows the Flow's elements for the record the test creates, deciding each decision the record settles (including formula resources, and lookups on data the test doesn't create, which find nothing in an Apex test). It asserts the fields the Flow is certain to set and the records it is certain to create. When the Flow is certain to stop the save with a custom error, the test expects that error, and a second test sets the fields that avoid it. For autolaunched Flows, it asserts output variables the Flow is certain to set. What the Flow does only on a decision outcome the command can't predict gets commented-out assertions. The generated tests have TODOs for anything the command can't fill in.\n\nOnly Apex tests count toward deploying Flows as active, so this command generates Apex, not Flow Builder tests.",
|
|
212
227
|
"examples": [
|
|
213
228
|
"Generate a test for one Flow:\n<%= config.bin %> <%= command.id %> --flow Account_After_Save",
|
|
214
229
|
"Generate tests for every active Flow the org has no coverage for:\n<%= config.bin %> <%= command.id %> --uncovered --target-org prod",
|
|
@@ -311,7 +326,101 @@
|
|
|
311
326
|
"flowcov:scaffold",
|
|
312
327
|
"scaffold:flowcov"
|
|
313
328
|
]
|
|
329
|
+
},
|
|
330
|
+
"flowcov:transform": {
|
|
331
|
+
"aliases": [],
|
|
332
|
+
"args": {},
|
|
333
|
+
"description": "Reads Flow coverage from the target org and maps it onto the project's Flow metadata files, so Flow coverage shows up next to Apex coverage in tools such as SonarQube, GitLab, Azure DevOps, or Codecov. Each executable element of a Flow (every element except the start element and resources such as variables and formulas) becomes one line: the line of its `<name>` in the `.flow-meta.xml` file, covered when any Apex test ran the element. A Flow's line coverage therefore equals its element coverage.\n\nCovers every active Flow and process that counts toward \"Deploy processes and flows as active\" and has a source file in the project. Paths in the reports are relative to --project-dir; run the command from the root your coverage tool expects. For SonarQube, the Flow files must be indexed (for example, include `**/*.flow-meta.xml` in `sonar.inclusions`) for their coverage to be imported.\n\nCoverage is read from FlowTestCoverage, which Salesforce fills in when Apex tests run in the org with coverage on (`sf apex run test --code-coverage`). Without `--code-coverage`, and in check-only deployments, Salesforce records no Flow coverage. When no Flow in the org has any coverage recorded, the command warns that the tests most likely ran without `--code-coverage`. When a Flow file's elements don't match the version the org covered, the command warns that its line coverage may be off.",
|
|
334
|
+
"examples": [
|
|
335
|
+
"Write a SonarQube generic coverage report to the coverage folder:\n<%= config.bin %> <%= command.id %> --target-org ci-sandbox --format sonar",
|
|
336
|
+
"Write Cobertura and lcov reports to a folder of your choice:\n<%= config.bin %> <%= command.id %> --target-org ci-sandbox --format cobertura --format lcov --output-dir reports"
|
|
337
|
+
],
|
|
338
|
+
"flags": {
|
|
339
|
+
"json": {
|
|
340
|
+
"description": "Format output as json.",
|
|
341
|
+
"helpGroup": "GLOBAL",
|
|
342
|
+
"name": "json",
|
|
343
|
+
"allowNo": false,
|
|
344
|
+
"type": "boolean"
|
|
345
|
+
},
|
|
346
|
+
"flags-dir": {
|
|
347
|
+
"helpGroup": "GLOBAL",
|
|
348
|
+
"name": "flags-dir",
|
|
349
|
+
"summary": "Import flag values from a directory.",
|
|
350
|
+
"hasDynamicHelp": false,
|
|
351
|
+
"multiple": false,
|
|
352
|
+
"type": "option"
|
|
353
|
+
},
|
|
354
|
+
"target-org": {
|
|
355
|
+
"char": "o",
|
|
356
|
+
"name": "target-org",
|
|
357
|
+
"noCacheDefault": true,
|
|
358
|
+
"required": true,
|
|
359
|
+
"summary": "Username or alias of the target org. Not required if the `target-org` configuration variable is already set.",
|
|
360
|
+
"hasDynamicHelp": true,
|
|
361
|
+
"multiple": false,
|
|
362
|
+
"type": "option"
|
|
363
|
+
},
|
|
364
|
+
"api-version": {
|
|
365
|
+
"description": "Override the api version used for api requests made by this command",
|
|
366
|
+
"name": "api-version",
|
|
367
|
+
"hasDynamicHelp": false,
|
|
368
|
+
"multiple": false,
|
|
369
|
+
"type": "option"
|
|
370
|
+
},
|
|
371
|
+
"format": {
|
|
372
|
+
"name": "format",
|
|
373
|
+
"required": true,
|
|
374
|
+
"summary": "Coverage format to write: sonar (SonarQube generic coverage), cobertura, or lcov.",
|
|
375
|
+
"hasDynamicHelp": false,
|
|
376
|
+
"multiple": true,
|
|
377
|
+
"options": [
|
|
378
|
+
"sonar",
|
|
379
|
+
"cobertura",
|
|
380
|
+
"lcov"
|
|
381
|
+
],
|
|
382
|
+
"type": "option"
|
|
383
|
+
},
|
|
384
|
+
"output-dir": {
|
|
385
|
+
"name": "output-dir",
|
|
386
|
+
"summary": "Folder to write the coverage reports to.",
|
|
387
|
+
"default": "coverage",
|
|
388
|
+
"hasDynamicHelp": false,
|
|
389
|
+
"multiple": false,
|
|
390
|
+
"type": "option"
|
|
391
|
+
},
|
|
392
|
+
"project-dir": {
|
|
393
|
+
"char": "d",
|
|
394
|
+
"name": "project-dir",
|
|
395
|
+
"summary": "Project root with the Flow metadata files. Report paths are relative to it.",
|
|
396
|
+
"default": ".",
|
|
397
|
+
"hasDynamicHelp": false,
|
|
398
|
+
"multiple": false,
|
|
399
|
+
"type": "option"
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
"hasDynamicHelp": true,
|
|
403
|
+
"hiddenAliases": [],
|
|
404
|
+
"id": "flowcov:transform",
|
|
405
|
+
"pluginAlias": "sf-flow-coverage",
|
|
406
|
+
"pluginName": "sf-flow-coverage",
|
|
407
|
+
"pluginType": "core",
|
|
408
|
+
"strict": true,
|
|
409
|
+
"summary": "Write Flow element coverage as SonarQube, Cobertura, or lcov coverage reports.",
|
|
410
|
+
"enableJsonFlag": true,
|
|
411
|
+
"isESM": true,
|
|
412
|
+
"relativePath": [
|
|
413
|
+
"lib",
|
|
414
|
+
"commands",
|
|
415
|
+
"flowcov",
|
|
416
|
+
"transform.js"
|
|
417
|
+
],
|
|
418
|
+
"aliasPermutations": [],
|
|
419
|
+
"permutations": [
|
|
420
|
+
"flowcov:transform",
|
|
421
|
+
"transform:flowcov"
|
|
422
|
+
]
|
|
314
423
|
}
|
|
315
424
|
},
|
|
316
|
-
"version": "0.
|
|
425
|
+
"version": "0.4.0"
|
|
317
426
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sf-flow-coverage",
|
|
3
3
|
"description": "Get your Salesforce org ready to deploy Flows as active: find uncovered Flows, gate coverage per Flow in pull requests, and scaffold Apex tests.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@oclif/core": "5.1.12",
|
|
7
7
|
"@salesforce/core": "9.4.6",
|