apextestlist 1.12.3 → 1.12.4
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 +8 -0
- package/lib/commands/apextests/list.d.ts +2 -5
- package/lib/commands/apextests/list.js +10 -64
- package/lib/commands/apextests/list.js.map +1 -1
- package/lib/core/listTests.d.ts +2 -0
- package/lib/core/listTests.js +54 -0
- package/lib/core/listTests.js.map +1 -0
- package/lib/parsers/manifestParser.d.ts +10 -0
- package/lib/parsers/manifestParser.js +27 -0
- package/lib/parsers/manifestParser.js.map +1 -0
- package/lib/parsers/testNameParser.d.ts +7 -0
- package/lib/parsers/testNameParser.js +19 -0
- package/lib/parsers/testNameParser.js.map +1 -0
- package/lib/parsers/testSuiteParser.d.ts +15 -0
- package/lib/parsers/testSuiteParser.js +40 -0
- package/lib/parsers/testSuiteParser.js.map +1 -0
- package/lib/readers/directorySearcher.d.ts +10 -0
- package/lib/readers/directorySearcher.js +82 -0
- package/lib/readers/directorySearcher.js.map +1 -0
- package/lib/readers/testSuiteSearcher.d.ts +9 -0
- package/lib/readers/testSuiteSearcher.js +74 -0
- package/lib/readers/testSuiteSearcher.js.map +1 -0
- package/lib/utils/concurrencyThreshold.d.ts +1 -0
- package/lib/utils/concurrencyThreshold.js +7 -0
- package/lib/utils/concurrencyThreshold.js.map +1 -0
- package/lib/utils/constants.d.ts +5 -0
- package/lib/utils/constants.js +7 -0
- package/lib/utils/constants.js.map +1 -0
- package/lib/{helpers → utils}/formatters.d.ts +1 -1
- package/lib/utils/formatters.js.map +1 -0
- package/lib/utils/getPackageDirectories.js.map +1 -0
- package/lib/{helpers → utils}/getRepoRoot.js +1 -1
- package/lib/utils/getRepoRoot.js.map +1 -0
- package/lib/utils/matchWildcard.d.ts +1 -0
- package/lib/utils/matchWildcard.js +5 -0
- package/lib/utils/matchWildcard.js.map +1 -0
- package/lib/utils/types.d.ts +22 -0
- package/lib/{helpers → utils}/types.js.map +1 -1
- package/lib/utils/validateTests.js.map +1 -0
- package/oclif.lock +51 -40
- package/oclif.manifest.json +2 -1
- package/package.json +2 -2
- package/lib/helpers/constants.d.ts +0 -2
- package/lib/helpers/constants.js +0 -4
- package/lib/helpers/constants.js.map +0 -1
- package/lib/helpers/formatters.js.map +0 -1
- package/lib/helpers/getPackageDirectories.js.map +0 -1
- package/lib/helpers/getRepoRoot.js.map +0 -1
- package/lib/helpers/parsers.d.ts +0 -32
- package/lib/helpers/parsers.js +0 -87
- package/lib/helpers/parsers.js.map +0 -1
- package/lib/helpers/readers.d.ts +0 -21
- package/lib/helpers/readers.js +0 -158
- package/lib/helpers/readers.js.map +0 -1
- package/lib/helpers/types.d.ts +0 -10
- package/lib/helpers/validateTests.js.map +0 -1
- /package/lib/{helpers → utils}/formatters.js +0 -0
- /package/lib/{helpers → utils}/getPackageDirectories.d.ts +0 -0
- /package/lib/{helpers → utils}/getPackageDirectories.js +0 -0
- /package/lib/{helpers → utils}/getRepoRoot.d.ts +0 -0
- /package/lib/{helpers → utils}/types.js +0 -0
- /package/lib/{helpers → utils}/validateTests.d.ts +0 -0
- /package/lib/{helpers → utils}/validateTests.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,14 @@
|
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
7
7
|
|
|
8
|
+
## [1.12.4](https://github.com/renatoliveira/apex-test-list/compare/v1.12.3...v1.12.4) (2025-06-14)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **deps:** bump @oclif/core from 4.3.0 to 4.3.3 ([#230](https://github.com/renatoliveira/apex-test-list/issues/230)) ([ec2ed5c](https://github.com/renatoliveira/apex-test-list/commit/ec2ed5c1f25ecc2366ebc219b71edc156440a45c))
|
|
14
|
+
* **deps:** bump @salesforce/source-deploy-retrieve ([#231](https://github.com/renatoliveira/apex-test-list/issues/231)) ([5c5d78c](https://github.com/renatoliveira/apex-test-list/commit/5c5d78c5990c61ce3f82b7cbd4ac02f7cc8f1e52))
|
|
15
|
+
|
|
8
16
|
## [1.12.3](https://github.com/renatoliveira/apex-test-list/compare/v1.12.2...v1.12.3) (2025-06-01)
|
|
9
17
|
|
|
10
18
|
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
-
|
|
3
|
-
tests: string[];
|
|
4
|
-
command: string;
|
|
5
|
-
};
|
|
2
|
+
import { ApextestsListResult } from '../../utils/types.js';
|
|
6
3
|
export default class ApextestsList extends SfCommand<ApextestsListResult> {
|
|
7
4
|
static readonly summary: string;
|
|
8
5
|
static readonly description: string;
|
|
9
6
|
static readonly examples: string[];
|
|
10
7
|
static readonly flags: {
|
|
11
|
-
format: import("@oclif/core/interfaces").OptionFlag<string
|
|
8
|
+
format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
9
|
manifest: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
10
|
'ignore-missing-tests': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
14
11
|
'ignore-package-directory': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
1
|
'use strict';
|
|
3
|
-
/* eslint-disable no-await-in-loop */
|
|
4
2
|
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
5
3
|
import { Messages } from '@salesforce/core';
|
|
6
|
-
import {
|
|
7
|
-
import { validateTests } from '../../helpers/validateTests.js';
|
|
8
|
-
import { extractTypeNamesFromManifestFile } from '../../helpers/parsers.js';
|
|
9
|
-
import { formatList } from '../../helpers/formatters.js';
|
|
10
|
-
import { searchDirectoryForTestClasses, searchDirectoryForTestNamesInTestSuites } from '../../helpers/readers.js';
|
|
4
|
+
import { listTests } from '../../core/listTests.js';
|
|
11
5
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
12
6
|
const messages = Messages.loadMessages('apextestlist', 'apextests.list');
|
|
13
7
|
export default class ApextestsList extends SfCommand {
|
|
@@ -20,6 +14,7 @@ export default class ApextestsList extends SfCommand {
|
|
|
20
14
|
description: messages.getMessage('flags.format.description'),
|
|
21
15
|
char: 'f',
|
|
22
16
|
required: false,
|
|
17
|
+
default: 'sf',
|
|
23
18
|
}),
|
|
24
19
|
manifest: Flags.string({
|
|
25
20
|
summary: messages.getMessage('flags.manifest.summary'),
|
|
@@ -51,63 +46,14 @@ export default class ApextestsList extends SfCommand {
|
|
|
51
46
|
};
|
|
52
47
|
async run() {
|
|
53
48
|
const { flags } = await this.parse(ApextestsList);
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const warnings = [];
|
|
63
|
-
// Get package directories full paths
|
|
64
|
-
const packageDirectories = await getPackageDirectories(ignoreDirs);
|
|
65
|
-
if (manifest) {
|
|
66
|
-
const manifestMetadata = await extractTypeNamesFromManifestFile(manifest);
|
|
67
|
-
testClassesNames = manifestMetadata.filter((name) => !name.endsWith('testSuite-meta.xml'));
|
|
68
|
-
}
|
|
69
|
-
// Loop through each directory and search for test classes
|
|
70
|
-
for (const directory of packageDirectories) {
|
|
71
|
-
const searchResult = await searchDirectoryForTestClasses(directory, testClassesNames);
|
|
72
|
-
allTestClasses.push(...searchResult.classes);
|
|
73
|
-
testSuitesNames.push(...searchResult.testSuites);
|
|
74
|
-
if (searchResult.warnings?.length) {
|
|
75
|
-
warnings.push(...searchResult.warnings);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
if (testSuitesNames.length > 0) {
|
|
79
|
-
for (const directory of packageDirectories.filter((dir) => dir.includes('testSuites'))) {
|
|
80
|
-
const testNames = await searchDirectoryForTestNamesInTestSuites(directory, packageDirectories);
|
|
81
|
-
allTestClasses.push(...testNames);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
let finalTestMethods = Array.from(new Set(allTestClasses.map((test) => test.trim())));
|
|
85
|
-
// If ignore-missing-tests is true, validate the test methods
|
|
86
|
-
if (ignoreMissingTests) {
|
|
87
|
-
const { validatedTests, warnings: validationWarnings } = await validateTests(finalTestMethods, packageDirectories);
|
|
88
|
-
finalTestMethods = validatedTests;
|
|
89
|
-
if (validationWarnings.length > 0) {
|
|
90
|
-
warnings.push(...validationWarnings);
|
|
91
|
-
}
|
|
92
|
-
if (validatedTests.length === 0) {
|
|
93
|
-
warnings.push('No test methods declared in your annotations were found in your package directories');
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
// Print all collected warnings
|
|
97
|
-
if (!noWarnings && warnings.length > 0) {
|
|
98
|
-
warnings.forEach((warning) => {
|
|
99
|
-
this.warn(warning);
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
finalTestMethods.sort((a, b) => a.localeCompare(b));
|
|
103
|
-
if (finalTestMethods.length === 0) {
|
|
104
|
-
this.warn('No test methods found');
|
|
105
|
-
return {
|
|
106
|
-
tests: [],
|
|
107
|
-
command: '',
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
const result = await formatList(format, finalTestMethods);
|
|
49
|
+
const result = await listTests({
|
|
50
|
+
format: flags.format,
|
|
51
|
+
manifest: flags.manifest,
|
|
52
|
+
ignoreMissingTests: flags['ignore-missing-tests'],
|
|
53
|
+
ignoreDirs: flags['ignore-package-directory'],
|
|
54
|
+
noWarnings: flags['no-warnings'],
|
|
55
|
+
warn: this.warn.bind(this),
|
|
56
|
+
});
|
|
111
57
|
this.log(result.command);
|
|
112
58
|
return result;
|
|
113
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/apextests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B,OAAO,MAAM,CAAC;IAChB,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/* eslint-disable no-await-in-loop */
|
|
2
|
+
import { getPackageDirectories } from '../utils/getPackageDirectories.js';
|
|
3
|
+
import { validateTests } from '../utils/validateTests.js';
|
|
4
|
+
import { extractTypeNamesFromManifestFile } from '../parsers/manifestParser.js';
|
|
5
|
+
import { formatList } from '../utils/formatters.js';
|
|
6
|
+
import { searchDirectoryForTestClasses } from '../readers/directorySearcher.js';
|
|
7
|
+
import { searchDirectoryForTestNamesInTestSuites } from '../readers/testSuiteSearcher.js';
|
|
8
|
+
export async function listTests({ format = 'sf', manifest, ignoreMissingTests = false, ignoreDirs = [], noWarnings = false, warn = () => { }, }) {
|
|
9
|
+
let testClassesNames = null;
|
|
10
|
+
const testSuitesNames = [];
|
|
11
|
+
const allTestClasses = [];
|
|
12
|
+
const warnings = [];
|
|
13
|
+
const packageDirectories = await getPackageDirectories(ignoreDirs);
|
|
14
|
+
if (manifest) {
|
|
15
|
+
const manifestMetadata = await extractTypeNamesFromManifestFile(manifest);
|
|
16
|
+
testClassesNames = manifestMetadata.filter((name) => !name.endsWith('testSuite-meta.xml'));
|
|
17
|
+
}
|
|
18
|
+
for (const directory of packageDirectories) {
|
|
19
|
+
const searchResult = await searchDirectoryForTestClasses(directory, testClassesNames);
|
|
20
|
+
allTestClasses.push(...searchResult.classes);
|
|
21
|
+
testSuitesNames.push(...searchResult.testSuites);
|
|
22
|
+
if (searchResult.warnings?.length) {
|
|
23
|
+
warnings.push(...searchResult.warnings);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (testSuitesNames.length > 0) {
|
|
27
|
+
for (const directory of packageDirectories.filter((dir) => dir.includes('testSuites'))) {
|
|
28
|
+
const testNames = await searchDirectoryForTestNamesInTestSuites(directory, packageDirectories);
|
|
29
|
+
allTestClasses.push(...testNames);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
let finalTestMethods = Array.from(new Set(allTestClasses.map((test) => test.trim())));
|
|
33
|
+
if (ignoreMissingTests) {
|
|
34
|
+
const { validatedTests, warnings: validationWarnings } = await validateTests(finalTestMethods, packageDirectories);
|
|
35
|
+
finalTestMethods = validatedTests;
|
|
36
|
+
warnings.push(...validationWarnings);
|
|
37
|
+
if (validatedTests.length === 0) {
|
|
38
|
+
warnings.push('No test methods declared in your annotations were found in your package directories');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (!noWarnings && warnings.length > 0) {
|
|
42
|
+
warnings.forEach(warn);
|
|
43
|
+
}
|
|
44
|
+
finalTestMethods.sort((a, b) => a.localeCompare(b));
|
|
45
|
+
if (finalTestMethods.length === 0) {
|
|
46
|
+
warn('No test methods found');
|
|
47
|
+
return {
|
|
48
|
+
tests: [],
|
|
49
|
+
command: '',
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return formatList(format, finalTestMethods);
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=listTests.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listTests.js","sourceRoot":"","sources":["../../src/core/listTests.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,gCAAgC,EAAE,MAAM,8BAA8B,CAAC;AAChF,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,uCAAuC,EAAE,MAAM,iCAAiC,CAAC;AAG1F,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,EAC9B,MAAM,GAAG,IAAI,EACb,QAAQ,EACR,kBAAkB,GAAG,KAAK,EAC1B,UAAU,GAAG,EAAE,EACf,UAAU,GAAG,KAAK,EAClB,IAAI,GAAG,GAAS,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CAAC;IACH,CAAC;IAED,IAAI,gBAAgB,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAEtF,IAAI,kBAAkB,EAAE,CAAC;QACvB,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,kBAAkB,EAAE,GAAG,MAAM,aAAa,CAC1E,gBAAgB,EAChB,kBAAkB,CACnB,CAAC;QACF,gBAAgB,GAAG,cAAc,CAAC;QAClC,QAAQ,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAC,CAAC;QACrC,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAChC,QAAQ,CAAC,IAAI,CAAC,qFAAqF,CAAC,CAAC;QACvG,CAAC;IACH,CAAC;IAED,IAAI,CAAC,UAAU,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAED,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;IAEpD,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClC,IAAI,CAAC,uBAAuB,CAAC,CAAC;QAC9B,OAAO;YACL,KAAK,EAAE,EAAE;YACT,OAAO,EAAE,EAAE;SACZ,CAAC;IACJ,CAAC;IAED,OAAO,UAAU,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Given a certain manifest file, reads that file and returns the classes,
|
|
3
|
+
* triggers and test suites members with their types as prefix.
|
|
4
|
+
*
|
|
5
|
+
* For example, as ApexClass:MyClass.
|
|
6
|
+
*
|
|
7
|
+
* @param manifestFile the path to the manifest file
|
|
8
|
+
* @returns a list of strings with the type and member names
|
|
9
|
+
*/
|
|
10
|
+
export declare function extractTypeNamesFromManifestFile(manifestFile: string): Promise<string[]>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { ComponentSet } from '@salesforce/source-deploy-retrieve';
|
|
4
|
+
/**
|
|
5
|
+
* Given a certain manifest file, reads that file and returns the classes,
|
|
6
|
+
* triggers and test suites members with their types as prefix.
|
|
7
|
+
*
|
|
8
|
+
* For example, as ApexClass:MyClass.
|
|
9
|
+
*
|
|
10
|
+
* @param manifestFile the path to the manifest file
|
|
11
|
+
* @returns a list of strings with the type and member names
|
|
12
|
+
*/
|
|
13
|
+
export async function extractTypeNamesFromManifestFile(manifestFile) {
|
|
14
|
+
const result = [];
|
|
15
|
+
if (!manifestFile || !existsSync(manifestFile)) {
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
const componentSet = await ComponentSet.fromManifest({ manifestPath: manifestFile });
|
|
19
|
+
for (const component of componentSet) {
|
|
20
|
+
const typeName = component.type.name;
|
|
21
|
+
if (['ApexClass', 'ApexTrigger', 'ApexTestSuite'].includes(typeName)) {
|
|
22
|
+
result.push(`${typeName}:${component.fullName}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return result.sort((a, b) => a.localeCompare(b));
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=manifestParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifestParser.js","sourceRoot":"","sources":["../../src/parsers/manifestParser.ts"],"names":[],"mappings":"AACA,YAAY,CAAC;AAEb,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,YAAY,EAAG,MAAM,oCAAoC,CAAC;AAEnE;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,gCAAgC,CAAC,YAAoB;IACzE,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,IAAI,CAAC,YAAY,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QAC/C,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,YAAY,GAAiB,MAAM,YAAY,CAAC,YAAY,CAAC,EAAC,YAAY,EAAE,YAAY,EAAC,CAAC,CAAC;IACjG,KAAK,MAAM,SAAS,IAAI,YAAY,EAAE,CAAC;QACrC,MAAM,QAAQ,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;QACrC,IAAI,CAAC,WAAW,EAAE,aAAa,EAAE,eAAe,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YACrE,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,IAAI,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses the line in an Apex file that contains the test names.
|
|
3
|
+
*
|
|
4
|
+
* @param testNames names of the tests in an Apex file line
|
|
5
|
+
* @returns list of the test classes
|
|
6
|
+
*/
|
|
7
|
+
export function parseTestsNames(testNames) {
|
|
8
|
+
if (!testNames || testNames.length === 0) {
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
// remove the prefix @Tests
|
|
12
|
+
return testNames
|
|
13
|
+
.join(' ')
|
|
14
|
+
.replace(/(@tests\s*:\s*)/gi, '')
|
|
15
|
+
.replace(/[,\s]+/g, ' ')
|
|
16
|
+
.trim()
|
|
17
|
+
.split(' ');
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=testNameParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testNameParser.js","sourceRoot":"","sources":["../../src/parsers/testNameParser.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,SAA0B;IACxD,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzC,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,2BAA2B;IAC3B,OAAO,SAAS;SACb,IAAI,CAAC,GAAG,CAAC;SACT,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC;SAChC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;SACvB,IAAI,EAAE;SACN,KAAK,CAAC,GAAG,CAAC,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Analyzes the content of a test suite xml file and returns the Apex classes
|
|
3
|
+
* included in it.
|
|
4
|
+
*
|
|
5
|
+
* @param data string with the content of the test suite xml file
|
|
6
|
+
* @returns a list of test classes names in the test suite
|
|
7
|
+
*/
|
|
8
|
+
export declare function parseTestSuiteFile(data: string): string[];
|
|
9
|
+
/**
|
|
10
|
+
* Parses the line in an Apex file that contains the test suites names.
|
|
11
|
+
*
|
|
12
|
+
* @param testNames names of the test suites in an Apex file line
|
|
13
|
+
* @returns list of the test suites
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseTestSuitesNames(testSuitesNames: string[] | null): string[];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
import { Parser } from 'xml2js';
|
|
3
|
+
/**
|
|
4
|
+
* Analyzes the content of a test suite xml file and returns the Apex classes
|
|
5
|
+
* included in it.
|
|
6
|
+
*
|
|
7
|
+
* @param data string with the content of the test suite xml file
|
|
8
|
+
* @returns a list of test classes names in the test suite
|
|
9
|
+
*/
|
|
10
|
+
export function parseTestSuiteFile(data) {
|
|
11
|
+
const result = [];
|
|
12
|
+
new Parser().parseString(data, (error, parsed) => {
|
|
13
|
+
if (error) {
|
|
14
|
+
throw error;
|
|
15
|
+
}
|
|
16
|
+
parsed.ApexTestSuite.testClassName.forEach((testSuite) => {
|
|
17
|
+
result.push(testSuite);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
return result.sort();
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Parses the line in an Apex file that contains the test suites names.
|
|
24
|
+
*
|
|
25
|
+
* @param testNames names of the test suites in an Apex file line
|
|
26
|
+
* @returns list of the test suites
|
|
27
|
+
*/
|
|
28
|
+
export function parseTestSuitesNames(testSuitesNames) {
|
|
29
|
+
if (!testSuitesNames || testSuitesNames.length === 0) {
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
// remove the prefix @testsuites
|
|
33
|
+
return testSuitesNames
|
|
34
|
+
.join(' ')
|
|
35
|
+
.replace(/(@testsuites\s*:\s*)/gi, '')
|
|
36
|
+
.replace(/[,\s]+/g, ' ')
|
|
37
|
+
.trim()
|
|
38
|
+
.split(' ');
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=testSuiteParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testSuiteParser.js","sourceRoot":"","sources":["../../src/parsers/testSuiteParser.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,IAAI,MAAM,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,MAAsD,EAAE,EAAE;QAC/F,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,KAAK,CAAC;QACd,CAAC;QACD,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;YACvD,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;AACvB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,eAAgC;IACnE,IAAI,CAAC,eAAe,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrD,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,gCAAgC;IAChC,OAAO,eAAe;SACnB,IAAI,CAAC,GAAG,CAAC;SACT,OAAO,CAAC,wBAAwB,EAAE,EAAE,CAAC;SACrC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;SACvB,IAAI,EAAE;SACN,KAAK,CAAC,GAAG,CAAC,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SearchResult } from '../utils/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Given a certain directory, search its contents for files that end with '.cls' or '.trigger'.
|
|
4
|
+
* Extracts the test names from the annotations on those files, and returns a list with those.
|
|
5
|
+
*
|
|
6
|
+
* @param directory directory within the project to search for files
|
|
7
|
+
* @param names names of test files
|
|
8
|
+
* @returns list of test classes
|
|
9
|
+
*/
|
|
10
|
+
export declare function searchDirectoryForTestClasses(directory: string, names: string[] | null): Promise<SearchResult>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
import { readdirSync, readFileSync } from 'node:fs';
|
|
3
|
+
import { queue } from 'async';
|
|
4
|
+
import { parseTestSuitesNames } from '../parsers/testSuiteParser.js';
|
|
5
|
+
import { parseTestsNames } from '../parsers/testNameParser.js';
|
|
6
|
+
import { TEST_CLASS_ANNOTATION_REGEX, TEST_NAME_REGEX, TEST_SUITE_NAME_REGEX } from '../utils/constants.js';
|
|
7
|
+
import { getConcurrencyThreshold } from '../utils/concurrencyThreshold.js';
|
|
8
|
+
/**
|
|
9
|
+
* Given a certain directory, search its contents for files that end with '.cls' or '.trigger'.
|
|
10
|
+
* Extracts the test names from the annotations on those files, and returns a list with those.
|
|
11
|
+
*
|
|
12
|
+
* @param directory directory within the project to search for files
|
|
13
|
+
* @param names names of test files
|
|
14
|
+
* @returns list of test classes
|
|
15
|
+
*/
|
|
16
|
+
export async function searchDirectoryForTestClasses(directory, names) {
|
|
17
|
+
const testClassesNames = new Set();
|
|
18
|
+
const testSuitesNames = new Set();
|
|
19
|
+
const warnings = [];
|
|
20
|
+
let readDir;
|
|
21
|
+
try {
|
|
22
|
+
readDir = readdirSync(directory, { recursive: true });
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
throw new Error(`Invalid or inaccessible directory: ${directory}`);
|
|
26
|
+
}
|
|
27
|
+
// Gets the list of Apex files (classes and triggers)
|
|
28
|
+
const apexFiles = readDir.filter((file) => {
|
|
29
|
+
if (!file.endsWith('.cls') && !file.endsWith('.trigger')) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
const fileFullName = file.split('/').pop()?.split('.');
|
|
33
|
+
if (!names) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
if (fileFullName && fileFullName.length > 0) {
|
|
37
|
+
const formattedName = `${fileFullName[1] === 'cls' ? 'ApexClass' : 'ApexTrigger'}:${fileFullName[0]}`;
|
|
38
|
+
return names.includes(formattedName);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
const testClassNameHandler = (fileName) => {
|
|
42
|
+
const path = `${directory}/${fileName}`;
|
|
43
|
+
const data = readFileSync(path, 'utf-8');
|
|
44
|
+
const testNameMatches = Array.from(data.matchAll(TEST_NAME_REGEX));
|
|
45
|
+
const testSuiteMatches = Array.from(data.matchAll(TEST_SUITE_NAME_REGEX));
|
|
46
|
+
const testClassAnnotationMatches = data.match(TEST_CLASS_ANNOTATION_REGEX);
|
|
47
|
+
let hasAnnotation = false;
|
|
48
|
+
if (testNameMatches.length > 0) {
|
|
49
|
+
hasAnnotation = true;
|
|
50
|
+
for (const match of testNameMatches) {
|
|
51
|
+
parseTestsNames(match).forEach((testMethod) => testClassesNames.add(testMethod));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (testSuiteMatches.length > 0) {
|
|
55
|
+
hasAnnotation = true;
|
|
56
|
+
for (const match of testSuiteMatches) {
|
|
57
|
+
parseTestSuitesNames(match).forEach((testMethod) => testSuitesNames.add(testMethod));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (testClassAnnotationMatches && testClassAnnotationMatches.length > 0) {
|
|
61
|
+
hasAnnotation = true;
|
|
62
|
+
testClassesNames.add(fileName.split('.').shift());
|
|
63
|
+
}
|
|
64
|
+
if (!hasAnnotation) {
|
|
65
|
+
warnings.push(`File "${fileName}" does not contain @tests, @testsuites, or @istest annotations`);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const testClassNameProcessor = queue((f, cb) => {
|
|
69
|
+
testClassNameHandler(f);
|
|
70
|
+
cb();
|
|
71
|
+
}, getConcurrencyThreshold());
|
|
72
|
+
await testClassNameProcessor.push(apexFiles);
|
|
73
|
+
if (testClassNameProcessor.length() > 0) {
|
|
74
|
+
await testClassNameProcessor.drain();
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
classes: Array.from(testClassesNames),
|
|
78
|
+
testSuites: Array.from(testSuitesNames),
|
|
79
|
+
warnings,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=directorySearcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directorySearcher.js","sourceRoot":"","sources":["../../src/readers/directorySearcher.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE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0B,IAAI,0BAA0B,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxE,aAAa,GAAG,IAAI,CAAC;YACrB,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAY,CAAC,CAAC;QAC9D,CAAC;QAED,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,QAAQ,CAAC,IAAI,CAAC,SAAS,QAAQ,gEAAgE,CAAC,CAAC;QACnG,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,sBAAsB,GAAG,KAAK,CAAC,CAAC,CAAS,EAAE,EAAuC,EAAE,EAAE;QAC1F,oBAAoB,CAAC,CAAC,CAAC,CAAC;QACxB,EAAE,EAAE,CAAC;IACP,CAAC,EAAE,uBAAuB,EAAE,CAAC,CAAC;IAE9B,MAAM,sBAAsB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAE7C,IAAI,sBAAsB,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;QACxC,MAAM,sBAAsB,CAAC,KAAK,EAAE,CAAC;IACvC,CAAC;IAED,OAAO;QACL,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC;QACrC,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC;QACvC,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Given a certain directory, search its contents for files that end with
|
|
3
|
+
* '.testSuite-meta.xml' and extract the class names mentioned in the test
|
|
4
|
+
* suites.
|
|
5
|
+
*
|
|
6
|
+
* @param directory directory within the project to search for files
|
|
7
|
+
* @returns a Promise<string> with a list of test names
|
|
8
|
+
*/
|
|
9
|
+
export declare function searchDirectoryForTestNamesInTestSuites(directory: string, packageDirectories: string[]): Promise<string[]>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
import { readdirSync, readFileSync } from 'node:fs';
|
|
3
|
+
import { queue } from 'async';
|
|
4
|
+
import { parseTestSuiteFile } from '../parsers/testSuiteParser.js';
|
|
5
|
+
import { getConcurrencyThreshold } from '../utils/concurrencyThreshold.js';
|
|
6
|
+
import { matchWildcard } from '../utils/matchWildcard.js';
|
|
7
|
+
import { searchDirectoryForTestClasses } from './directorySearcher.js';
|
|
8
|
+
/**
|
|
9
|
+
* Given a certain directory, search its contents for files that end with
|
|
10
|
+
* '.testSuite-meta.xml' and extract the class names mentioned in the test
|
|
11
|
+
* suites.
|
|
12
|
+
*
|
|
13
|
+
* @param directory directory within the project to search for files
|
|
14
|
+
* @returns a Promise<string> with a list of test names
|
|
15
|
+
*/
|
|
16
|
+
export async function searchDirectoryForTestNamesInTestSuites(directory, packageDirectories) {
|
|
17
|
+
const testClassesNames = new Set();
|
|
18
|
+
let readDir;
|
|
19
|
+
try {
|
|
20
|
+
readDir = readdirSync(directory, { recursive: true });
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
throw new Error(`Invalid or inaccessible directory: ${directory}`);
|
|
24
|
+
}
|
|
25
|
+
// Gets the list of test suites
|
|
26
|
+
const suiteFiles = readDir.filter((file) => file.endsWith('.testSuite-meta.xml'));
|
|
27
|
+
const wildcards = new Set();
|
|
28
|
+
let requiresWildcardSearch = false;
|
|
29
|
+
// Function that handles the parsing of test suites and helps to build the
|
|
30
|
+
// list of test classes for the next steps
|
|
31
|
+
const testSuiteNameHandler = (fileName) => {
|
|
32
|
+
const path = `${directory}/${fileName}`;
|
|
33
|
+
const data = readFileSync(path, 'utf-8');
|
|
34
|
+
const classes = parseTestSuiteFile(data);
|
|
35
|
+
// TODO: Support for wildcards
|
|
36
|
+
for (const test of classes) {
|
|
37
|
+
if (test.includes('*')) {
|
|
38
|
+
requiresWildcardSearch = true;
|
|
39
|
+
wildcards.add(test);
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
testClassesNames.add(test);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
// define the processors
|
|
46
|
+
const testSuiteNameProcessor = queue((f, cb) => {
|
|
47
|
+
testSuiteNameHandler(f);
|
|
48
|
+
cb();
|
|
49
|
+
}, getConcurrencyThreshold());
|
|
50
|
+
// initialize the processor with the names of files we want to process
|
|
51
|
+
await testSuiteNameProcessor.push(suiteFiles);
|
|
52
|
+
// make sure no dangling process is left before continuing
|
|
53
|
+
if (testSuiteNameProcessor.length() > 0) {
|
|
54
|
+
await testSuiteNameProcessor.drain();
|
|
55
|
+
}
|
|
56
|
+
if (requiresWildcardSearch && packageDirectories) {
|
|
57
|
+
for (const pkgDir of packageDirectories) {
|
|
58
|
+
// eslint-disable-next-line no-await-in-loop
|
|
59
|
+
const searchResult = await searchDirectoryForTestClasses(pkgDir, null);
|
|
60
|
+
const testClassesInDir = searchResult.classes;
|
|
61
|
+
for (const test of testClassesInDir) {
|
|
62
|
+
// if the test class name matches the wildcard, add it to the list
|
|
63
|
+
for (const wildcard of wildcards) {
|
|
64
|
+
if (!matchWildcard(wildcard, test)) {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
testClassesNames.add(test);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return Array.from(testClassesNames).sort();
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=testSuiteSearcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testSuiteSearcher.js","sourceRoot":"","sources":["../../src/readers/testSuiteSearcher.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAE9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,aAAa,E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|
+
export function getConcurrencyThreshold() {
|
|
4
|
+
const AVAILABLE_PARALLELISM = availableParallelism ? availableParallelism() : Infinity;
|
|
5
|
+
return Math.min(AVAILABLE_PARALLELISM, 6);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=concurrencyThreshold.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"concurrencyThreshold.js","sourceRoot":"","sources":["../../src/utils/concurrencyThreshold.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE/C,MAAM,UAAU,uBAAuB;IACrC,MAAM,qBAAqB,GAAW,oBAAoB,CAAC,CAAC,CAAC,oBAAoB,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;IAE/F,OAAO,IAAI,CAAC,GAAG,CAAC,qBAAqB,EAAE,CAAC,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const SFDX_PROJECT_FILE_NAME = "sfdx-project.json";
|
|
2
|
+
export declare const SEARCHABLE_METADATA_FOLDERS: string[];
|
|
3
|
+
export declare const TEST_NAME_REGEX: RegExp;
|
|
4
|
+
export declare const TEST_SUITE_NAME_REGEX: RegExp;
|
|
5
|
+
export declare const TEST_CLASS_ANNOTATION_REGEX: RegExp;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
export const SFDX_PROJECT_FILE_NAME = 'sfdx-project.json';
|
|
3
|
+
export const SEARCHABLE_METADATA_FOLDERS = ['classes', 'triggers', 'testSuites'];
|
|
4
|
+
export const TEST_NAME_REGEX = /@tests\s*:\s*([^/\n]+)/gi;
|
|
5
|
+
export const TEST_SUITE_NAME_REGEX = /@testsuites\s*:\s*([^/\n]+)/gi;
|
|
6
|
+
export const TEST_CLASS_ANNOTATION_REGEX = /@istest/gi;
|
|
7
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,MAAM,CAAC,MAAM,sBAAsB,GAAG,mBAAmB,CAAC;AAC1D,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;AACjF,MAAM,CAAC,MAAM,eAAe,GAAG,0BAA0B,CAAC;AAC1D,MAAM,CAAC,MAAM,qBAAqB,GAAG,+BAA+B,CAAC;AACrE,MAAM,CAAC,MAAM,2BAA2B,GAAG,WAAW,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ApextestsListResult } from '../
|
|
1
|
+
import { ApextestsListResult } from '../utils/types.js';
|
|
2
2
|
export declare function formatList(format: string, tests: string[]): Promise<ApextestsListResult>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatters.js","sourceRoot":"","sources":["../../src/utils/formatters.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAGb,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,MAAc,EAAE,KAAe;IAC9D,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,IAAI;YACP,OAAO,OAAO,CAAC,OAAO,CAAC;gBACrB,KAAK;gBACL,OAAO,EAAE,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;aACtC,CAAC,CAAC;QACL,KAAK,KAAK;YACR,OAAO,OAAO,CAAC,OAAO,CAAC;gBACrB,KAAK;gBACL,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;aACzB,CAAC,CAAC;QACL;YACE,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACvC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPackageDirectories.js","sourceRoot":"","sources":["../../src/utils/getPackageDirectories.ts"],"names":[],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AAED,KAAK,UAAU,mBAAmB,CAAC,WAAmB,EAAE,iBAA2B;IACjF,MAAM,UAAU,GAAa,EAAE,CAAC;IAChC,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;IAEzC,MAAM,eAAe,GAAG,MAAM,OAAO,CAAC,GAAG,CACvC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QACvB,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QACzC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEnC,IAAI,KAAK,CAAC,WAAW,EAAE,IAAI,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5D,OAAO,CAAC,QAAQ,CAAC,CAAC;QACpB,CAAC;aAAM,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YAC/B,OAAO,mBAAmB,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC;QAC1D,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC,CACH,CAAC;IAEF,KAAK,MAAM,KAAK,IAAI,eAAe,EAAE,CAAC;QACpC,UAAU,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
import { access } from 'node:fs/promises';
|
|
3
3
|
import { join, dirname } from 'node:path';
|
|
4
|
-
import { SFDX_PROJECT_FILE_NAME } from '
|
|
4
|
+
import { SFDX_PROJECT_FILE_NAME } from '../utils/constants.js';
|
|
5
5
|
async function findRepoRoot(dir) {
|
|
6
6
|
const filePath = join(dir, SFDX_PROJECT_FILE_NAME);
|
|
7
7
|
try {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRepoRoot.js","sourceRoot":"","sources":["../../src/utils/getRepoRoot.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,KAAK,UAAU,YAAY,CACzB,GAAW;IAEX,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,sBAAsB,CAAC,CAAC;IACnD,IAAI,CAAC;QACH,6DAA6D;QAC7D,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;QACvB,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,gBAAgB,EAAE,QAAQ,EAAE,CAAC;IACvD,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACtB,4DAA4D;YAC5D,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAC1E,CAAC;QACD,6CAA6C;QAC7C,OAAO,YAAY,CAAC,SAAS,CAAC,CAAC;IACjC,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW;IAC/B,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IACjC,OAAO,YAAY,CAAC,UAAU,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function matchWildcard(wildcard: string, test: string): boolean;
|