apextestlist 1.0.2 → 1.2.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/lib/commands/apextests/list.d.ts +3 -2
- package/lib/commands/apextests/list.js +63 -20
- package/lib/commands/apextests/list.js.map +1 -1
- package/lib/helpers/constants.d.ts +1 -0
- package/lib/helpers/constants.js +3 -0
- package/lib/helpers/constants.js.map +1 -0
- package/lib/helpers/getPackageDirectories.d.ts +1 -0
- package/lib/helpers/getPackageDirectories.js +45 -0
- package/lib/helpers/getPackageDirectories.js.map +1 -0
- package/lib/helpers/getRepoRoot.d.ts +1 -0
- package/lib/helpers/getRepoRoot.js +12 -0
- package/lib/helpers/getRepoRoot.js.map +1 -0
- package/lib/helpers/types.d.ts +5 -0
- package/lib/helpers/types.js +3 -0
- package/lib/helpers/types.js.map +1 -0
- package/messages/apextests.list.md +9 -0
- package/oclif.lock +1606 -746
- package/oclif.manifest.json +13 -12
- package/package.json +10 -7
- package/npm-shrinkwrap.json +0 -23647
|
@@ -8,12 +8,13 @@ export default class ApextestsList extends SfCommand<ApextestsListResult> {
|
|
|
8
8
|
static readonly description: string;
|
|
9
9
|
static readonly examples: string[];
|
|
10
10
|
static readonly flags: {
|
|
11
|
-
directory: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
11
|
format: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
manifest: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
13
|
};
|
|
14
14
|
protected static getConcurrencyThreshold(): number;
|
|
15
15
|
private static parseTestsNames;
|
|
16
|
-
private static
|
|
16
|
+
private static searchTestClasses;
|
|
17
17
|
private static formatList;
|
|
18
|
+
private static extractClassNamesFromManifestFile;
|
|
18
19
|
run(): Promise<ApextestsListResult>;
|
|
19
20
|
}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* eslint-disable no-await-in-loop */
|
|
1
3
|
import * as fs from 'node:fs';
|
|
2
4
|
import { availableParallelism } from 'node:os';
|
|
3
5
|
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
4
6
|
import { Messages } from '@salesforce/core';
|
|
5
7
|
import { queue } from 'async';
|
|
8
|
+
import { Parser } from 'xml2js';
|
|
9
|
+
import { getPackageDirectories } from '../../helpers/getPackageDirectories.js';
|
|
6
10
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
7
11
|
const messages = Messages.loadMessages('apextestlist', 'apextests.list');
|
|
8
12
|
const TEST_NAME_REGEX = /(@(Tests|TestSuites)).+/g;
|
|
@@ -11,19 +15,18 @@ export default class ApextestsList extends SfCommand {
|
|
|
11
15
|
static description = messages.getMessage('description');
|
|
12
16
|
static examples = messages.getMessages('examples');
|
|
13
17
|
static flags = {
|
|
14
|
-
directory: Flags.string({
|
|
15
|
-
summary: messages.getMessage('flags.directory.summary'),
|
|
16
|
-
description: messages.getMessage('flags.directory.description'),
|
|
17
|
-
char: 'd',
|
|
18
|
-
required: false,
|
|
19
|
-
}),
|
|
20
18
|
format: Flags.string({
|
|
21
19
|
summary: messages.getMessage('flags.format.summary'),
|
|
22
20
|
description: messages.getMessage('flags.format.description'),
|
|
23
21
|
char: 'f',
|
|
24
22
|
required: false,
|
|
25
23
|
}),
|
|
26
|
-
|
|
24
|
+
manifest: Flags.string({
|
|
25
|
+
summary: messages.getMessage('flags.manifest.summary'),
|
|
26
|
+
description: messages.getMessage('flags.manifest.description'),
|
|
27
|
+
char: 'x',
|
|
28
|
+
required: false,
|
|
29
|
+
}),
|
|
27
30
|
};
|
|
28
31
|
static getConcurrencyThreshold() {
|
|
29
32
|
const AVAILABLE_PARALLELISM = availableParallelism ? availableParallelism() : Infinity;
|
|
@@ -41,12 +44,8 @@ export default class ApextestsList extends SfCommand {
|
|
|
41
44
|
.map((line) => line.trim())
|
|
42
45
|
.filter((line) => line);
|
|
43
46
|
}
|
|
44
|
-
static async
|
|
47
|
+
static async searchTestClasses(directory, names) {
|
|
45
48
|
const testMethodsNames = [];
|
|
46
|
-
// check if the provided directory exists
|
|
47
|
-
if (!directory) {
|
|
48
|
-
throw new Error('Invalid directory.');
|
|
49
|
-
}
|
|
50
49
|
let readDir;
|
|
51
50
|
try {
|
|
52
51
|
readDir = fs.readdirSync(directory, { recursive: true });
|
|
@@ -54,7 +53,19 @@ export default class ApextestsList extends SfCommand {
|
|
|
54
53
|
catch (error) {
|
|
55
54
|
throw new Error('Invalid directory.');
|
|
56
55
|
}
|
|
57
|
-
const localFiles = readDir.filter((file) =>
|
|
56
|
+
const localFiles = readDir.filter((file) => {
|
|
57
|
+
if (!file.endsWith('.cls') && !file.endsWith('.trigger')) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
const fileFullName = file.split('/').pop()?.split('.');
|
|
61
|
+
if (!names) {
|
|
62
|
+
return fileFullName;
|
|
63
|
+
}
|
|
64
|
+
if (fileFullName && fileFullName.length > 0) {
|
|
65
|
+
const formattedName = `${fileFullName[1] === 'cls' ? 'ApexClass' : 'ApexTrigger'}:${fileFullName[0]}`;
|
|
66
|
+
return names.includes(formattedName);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
58
69
|
const handler = (fileName) => {
|
|
59
70
|
const path = `${directory}/${fileName}`;
|
|
60
71
|
const data = fs.readFileSync(path, 'utf-8');
|
|
@@ -87,19 +98,51 @@ export default class ApextestsList extends SfCommand {
|
|
|
87
98
|
throw new Error('Invalid format.');
|
|
88
99
|
}
|
|
89
100
|
}
|
|
101
|
+
static async extractClassNamesFromManifestFile(manifestFile) {
|
|
102
|
+
const result = [];
|
|
103
|
+
if (!manifestFile || !fs.existsSync(manifestFile)) {
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
const xmlParser = new Parser();
|
|
107
|
+
await xmlParser
|
|
108
|
+
.parseStringPromise(fs.readFileSync(manifestFile, 'utf-8'))
|
|
109
|
+
.then((parsed) => {
|
|
110
|
+
parsed.Package.types.forEach((type) => {
|
|
111
|
+
if (type.name.includes('ApexClass') || type.name.includes('ApexTrigger')) {
|
|
112
|
+
type.members.forEach((member) => {
|
|
113
|
+
result.push(`${type.name}:${member}`);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
})
|
|
118
|
+
.catch((error) => {
|
|
119
|
+
throw error;
|
|
120
|
+
});
|
|
121
|
+
return result.sort((a, b) => a.localeCompare(b));
|
|
122
|
+
}
|
|
90
123
|
async run() {
|
|
91
124
|
const { flags } = await this.parse(ApextestsList);
|
|
92
|
-
const directory = flags.directory ?? '.';
|
|
93
125
|
const format = flags.format ?? 'sf';
|
|
94
|
-
|
|
95
|
-
throw new Error('Directory must be provided.');
|
|
96
|
-
}
|
|
126
|
+
const manifest = flags.manifest ?? undefined;
|
|
97
127
|
let result = null;
|
|
98
|
-
|
|
99
|
-
|
|
128
|
+
let testClassesNames = null;
|
|
129
|
+
// Get package directories
|
|
130
|
+
const packageDirectories = await getPackageDirectories();
|
|
131
|
+
if (manifest) {
|
|
132
|
+
testClassesNames = await ApextestsList.extractClassNamesFromManifestFile(manifest);
|
|
133
|
+
}
|
|
134
|
+
const allTestMethods = [];
|
|
135
|
+
// Loop through each directory and search for test classes
|
|
136
|
+
for (const directory of packageDirectories) {
|
|
137
|
+
const testMethodsInDir = await ApextestsList.searchTestClasses(directory, testClassesNames);
|
|
138
|
+
allTestMethods.push(...testMethodsInDir);
|
|
139
|
+
}
|
|
140
|
+
allTestMethods.sort((a, b) => a.localeCompare(b));
|
|
141
|
+
if (allTestMethods.length > 0) {
|
|
142
|
+
result = ApextestsList.formatList(format, allTestMethods);
|
|
100
143
|
}
|
|
101
144
|
if (!result) {
|
|
102
|
-
throw new Error('No
|
|
145
|
+
throw new Error('No test methods found');
|
|
103
146
|
}
|
|
104
147
|
this.log((await result).command);
|
|
105
148
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/apextests/list.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/apextests/list.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,qCAAqC;AAErC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAE/E,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;AACzE,MAAM,eAAe,GAAG,0BAA0B,CAAC;AAQnD,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,SAA8B;IAChE,MAAM,CAAU,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACzD,MAAM,CAAU,WAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,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AAI,CAAC;QAE7C,0BAA0B;QAC1B,MAAM,kBAAkB,GAAG,MAAM,qBAAqB,EAAE,CAAC;QAEzD,IAAI,QAAQ,EAAE,CAAC;YACb,gBAAgB,GAAG,MAAM,aAAa,CAAC,iCAAiC,CAAC,QAAQ,CAAC,CAAC;QACrF,CAAC;QAED,MAAM,cAAc,GAAa,EAAE,CAAC;QAEpC,0DAA0D;QAC1D,KAAK,MAAM,SAAS,IAAI,kBAAkB,EAAE,CAAC;YAC3C,MAAM,gBAAgB,GAAG,MAAM,aAAa,CAAC,iBAAiB,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;YAC5F,cAAc,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,CAAC;QAC3C,CAAC;QAED,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;QAElD,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9B,MAAM,GAAG,aAAa,CAAC,UAAU,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;QAC5D,CAAC;QAED,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAC3C,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC;QAEjC,OAAO,MAAM,CAAC;IAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SFDX_PROJECT_FILE_NAME = "sfdx-project.json";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/helpers/constants.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,MAAM,CAAC,MAAM,sBAAsB,GAAG,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getPackageDirectories(): Promise<string[]>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* eslint-disable no-await-in-loop */
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
|
+
import { resolve, join } from 'node:path';
|
|
5
|
+
import { readFile, readdir, stat } from 'node:fs/promises';
|
|
6
|
+
import { SFDX_PROJECT_FILE_NAME } from './constants.js';
|
|
7
|
+
import { getRepoRoot } from './getRepoRoot.js';
|
|
8
|
+
export async function getPackageDirectories() {
|
|
9
|
+
const repoRoot = await getRepoRoot();
|
|
10
|
+
process.chdir(repoRoot);
|
|
11
|
+
const dxConfigPath = resolve(repoRoot, SFDX_PROJECT_FILE_NAME);
|
|
12
|
+
if (!existsSync(dxConfigPath)) {
|
|
13
|
+
throw Error(`Salesforce DX Config File does not exist in this path: ${dxConfigPath}`);
|
|
14
|
+
}
|
|
15
|
+
const sfdxProjectRaw = await readFile(dxConfigPath, 'utf-8');
|
|
16
|
+
const sfdxProject = JSON.parse(sfdxProjectRaw);
|
|
17
|
+
const packageDirectories = sfdxProject.packageDirectories.map((directory) => resolve(repoRoot, directory.path));
|
|
18
|
+
const metadataPaths = [];
|
|
19
|
+
for (const directory of packageDirectories) {
|
|
20
|
+
const classesPath = await searchForSubFolders(directory, ['classes', 'triggers']);
|
|
21
|
+
if (classesPath.length > 0) {
|
|
22
|
+
metadataPaths.push(...classesPath);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return metadataPaths;
|
|
26
|
+
}
|
|
27
|
+
async function searchForSubFolders(dxDirectory, subDirectoryNames) {
|
|
28
|
+
const foundPaths = [];
|
|
29
|
+
const files = await readdir(dxDirectory);
|
|
30
|
+
for (const file of files) {
|
|
31
|
+
const filePath = join(dxDirectory, file);
|
|
32
|
+
const stats = await stat(filePath);
|
|
33
|
+
// Check if current directory is one of the desired sub-folders
|
|
34
|
+
if (stats.isDirectory() && subDirectoryNames.includes(file)) {
|
|
35
|
+
foundPaths.push(filePath);
|
|
36
|
+
}
|
|
37
|
+
// Recursively search sub-directories that aren't the target folders
|
|
38
|
+
else if (stats.isDirectory()) {
|
|
39
|
+
const result = await searchForSubFolders(filePath, subDirectoryNames);
|
|
40
|
+
foundPaths.push(...result);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return foundPaths;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=getPackageDirectories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPackageDirectories.js","sourceRoot":"","sources":["../../src/helpers/getPackageDirectories.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,qCAAqC;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,MAAM,CAAC,KAAK,UAAU,qBAAqB;IACzC,MAAM,QAAQ,GAAG,MAAM,WAAW,EAAE,CAAC;IACrC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACxB,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAAC;IAC/D,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QAC9B,MAAM,KAAK,CAAC,0DAA0D,YAAY,EAAE,CAAC,CAAC;IACxF,CAAC;IAED,MAAM,cAAc,GAAW,MAAM,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IACrE,MAAM,WAAW,GAAgB,IAAI,CAAC,KAAK,CAAC,cAAc,CAAgB,CAAC;IAC3E,MAAM,kBAAkB,GAAG,WAAW,CAAC,kBAAkB,CAAC,GAAG,CA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|
|
1
|
+
export declare function getRepoRoot(): Promise<string>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
import { promises as fsPromises, readFile, stat, readdir } from 'node:fs';
|
|
3
|
+
import git from 'isomorphic-git';
|
|
4
|
+
export async function getRepoRoot() {
|
|
5
|
+
const fs = { promises: fsPromises, readFile, stat, readdir };
|
|
6
|
+
const repoRoot = await git.findRoot({
|
|
7
|
+
fs,
|
|
8
|
+
filepath: process.cwd(),
|
|
9
|
+
});
|
|
10
|
+
return repoRoot;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=getRepoRoot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRepoRoot.js","sourceRoot":"","sources":["../../src/helpers/getRepoRoot.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,GAAG,MAAM,gBAAgB,CAAC;AAEjC,MAAM,CAAC,KAAK,UAAU,WAAW;IAC/B,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IAC7D,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC;QAClC,EAAE;QACF,QAAQ,EAAE,OAAO,CAAC,GAAG,EAAE;KACxB,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/helpers/types.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC"}
|
|
@@ -22,7 +22,16 @@ Format of the output.
|
|
|
22
22
|
|
|
23
23
|
By default, the format being returned is a list in the format that can be merged with the test flags of the Salesforce CLI deploy and validate commands. Available formats are `sf` (default) and `csv`.
|
|
24
24
|
|
|
25
|
+
# flags.manifest.summary
|
|
26
|
+
|
|
27
|
+
Manifest XML file.
|
|
28
|
+
|
|
29
|
+
# flags.manifest.description
|
|
30
|
+
|
|
31
|
+
When you specify a manifest file, the plugin will not search directories for all classes with annotations, but instead will read the manifest file and search for those classes within the specified directory.
|
|
32
|
+
|
|
25
33
|
# examples
|
|
26
34
|
|
|
27
35
|
- <%= config.bin %> <%= command.id %> --format csv
|
|
28
36
|
- <%= config.bin %> <%= command.id %> --format sf --directory force-app
|
|
37
|
+
- <%= config.bin %> <%= command.id %> --format sf --manifest package.xml
|