@salesforce/cli-plugins-testkit 3.0.2 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/execCmd.d.ts +1 -1
- package/lib/hubAuth.js +1 -1
- package/lib/testSession.d.ts +2 -0
- package/lib/testSession.js +16 -1
- package/package.json +1 -1
package/lib/execCmd.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export declare type ExecCmdOptions = ExecOptions & BaseExecOptions;
|
|
|
22
22
|
declare type ExcludeMethods<T> = Pick<T, NonNullable<{
|
|
23
23
|
[K in keyof T]: T[K] extends (_: any) => any ? never : K;
|
|
24
24
|
}[keyof T]>>;
|
|
25
|
-
declare type JsonOutput<T> = {
|
|
25
|
+
export declare type JsonOutput<T> = {
|
|
26
26
|
status: number;
|
|
27
27
|
result: T;
|
|
28
28
|
} & Partial<ExcludeMethods<SfError>>;
|
package/lib/hubAuth.js
CHANGED
|
@@ -76,7 +76,7 @@ const testkitHubAuth = (homeDir, authStrategy = (0, exports.getAuthStrategy)())
|
|
|
76
76
|
if (authStrategy === 'JWT') {
|
|
77
77
|
logger('trying jwt auth');
|
|
78
78
|
const jwtKey = (0, exports.prepareForJwt)(homeDir);
|
|
79
|
-
const results = shell.exec(`
|
|
79
|
+
const results = shell.exec(`sf login jwt org --set-default-dev-hub --username ${kit_1.env.getString('TESTKIT_HUB_USERNAME', '')} --clientid ${kit_1.env.getString('TESTKIT_JWT_CLIENT_ID', '')} --keyfile ${jwtKey} --instance-url ${kit_1.env.getString('TESTKIT_HUB_INSTANCE', DEFAULT_INSTANCE_URL)}`, execOpts);
|
|
80
80
|
if (results.code !== 0) {
|
|
81
81
|
throw new Error(`jwt:grant for org ${kit_1.env.getString('TESTKIT_HUB_USERNAME', 'TESTKIT_HUB_USERNAME was not set')} failed with exit code: ${results.code}\n ${results.stdout + results.stderr}`);
|
|
82
82
|
}
|
package/lib/testSession.d.ts
CHANGED
|
@@ -72,6 +72,7 @@ export declare class TestSession extends AsyncOptionalCreatable<TestSessionOptio
|
|
|
72
72
|
project?: TestProject;
|
|
73
73
|
rmRetryConfig: Partial<RetryConfig<void>>;
|
|
74
74
|
orgs: Map<string, AuthFields>;
|
|
75
|
+
hubOrg: AuthFields;
|
|
75
76
|
private debug;
|
|
76
77
|
private cwdStub?;
|
|
77
78
|
private overriddenDir?;
|
|
@@ -80,6 +81,7 @@ export declare class TestSession extends AsyncOptionalCreatable<TestSessionOptio
|
|
|
80
81
|
private zipDir;
|
|
81
82
|
private options;
|
|
82
83
|
private shelljsExecOptions;
|
|
84
|
+
private orgsAliases;
|
|
83
85
|
constructor(options?: TestSessionOptions);
|
|
84
86
|
/**
|
|
85
87
|
* Get an existing test session created with the same options,
|
package/lib/testSession.js
CHANGED
|
@@ -54,6 +54,7 @@ class TestSession extends kit_1.AsyncOptionalCreatable {
|
|
|
54
54
|
this.shelljsExecOptions = {
|
|
55
55
|
silent: true,
|
|
56
56
|
};
|
|
57
|
+
this.orgsAliases = ['default'];
|
|
57
58
|
this.options = options;
|
|
58
59
|
this.debug = (0, debug_1.debug)('testkit:session');
|
|
59
60
|
this.zipDir = zip_1.zipDir;
|
|
@@ -93,6 +94,16 @@ class TestSession extends kit_1.AsyncOptionalCreatable {
|
|
|
93
94
|
process.env.USERPROFILE = process.env.HOME = this.homeDir = kit_1.env.getString('TESTKIT_HOMEDIR', this.dir);
|
|
94
95
|
process.env.SFDX_USE_GENERIC_UNIX_KEYCHAIN = 'true';
|
|
95
96
|
(0, hubAuth_1.testkitHubAuth)(this.homeDir, authStrategy);
|
|
97
|
+
if (authStrategy !== 'NONE') {
|
|
98
|
+
const config = shell.exec('sf config get target-dev-hub --json', this.shelljsExecOptions);
|
|
99
|
+
const configResults = JSON.parse(config.stdout);
|
|
100
|
+
const usernameOrAlias = configResults.result.find((org) => org.name === 'target-dev-hub')?.value;
|
|
101
|
+
if (usernameOrAlias) {
|
|
102
|
+
const displayEnv = shell.exec(`sf env display -e ${usernameOrAlias} --json`, this.shelljsExecOptions);
|
|
103
|
+
const displayEnvResults = JSON.parse(displayEnv.stdout);
|
|
104
|
+
this.hubOrg = displayEnvResults.result;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
96
107
|
}
|
|
97
108
|
/**
|
|
98
109
|
* Get an existing test session created with the same options,
|
|
@@ -167,7 +178,7 @@ class TestSession extends kit_1.AsyncOptionalCreatable {
|
|
|
167
178
|
async deleteOrgs() {
|
|
168
179
|
if (!kit_1.env.getString('TESTKIT_ORG_USERNAME') && this.orgs.size > 0) {
|
|
169
180
|
for (const org of [...this.orgs.keys()]) {
|
|
170
|
-
if (org
|
|
181
|
+
if (this.orgsAliases.includes(org))
|
|
171
182
|
continue;
|
|
172
183
|
this.debug(`Deleting test org: ${org}`);
|
|
173
184
|
const rv = shell.exec(`sf env delete scratch -o ${org} -p`, this.shelljsExecOptions);
|
|
@@ -245,6 +256,10 @@ class TestSession extends kit_1.AsyncOptionalCreatable {
|
|
|
245
256
|
if (org.setDefault) {
|
|
246
257
|
this.orgs.set('default', jsonOutput.result.authFields);
|
|
247
258
|
}
|
|
259
|
+
if (org.alias) {
|
|
260
|
+
this.orgsAliases.push(org.alias);
|
|
261
|
+
this.orgs.set(org.alias, jsonOutput.result.authFields);
|
|
262
|
+
}
|
|
248
263
|
}
|
|
249
264
|
};
|
|
250
265
|
let attempts = 0;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/cli-plugins-testkit",
|
|
3
3
|
"description": "Provides test utilities to assist Salesforce CLI plug-in authors with writing non-unit tests (NUT).",
|
|
4
|
-
"version": "3.0
|
|
4
|
+
"version": "3.1.0",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"main": "lib/index.js",
|