@salesforce/cli-plugins-testkit 3.0.3 → 3.1.1

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 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>>;
@@ -78,7 +78,8 @@ export declare enum Interaction {
78
78
  SELECT = " ",
79
79
  Yes = "Y\r",
80
80
  No = "N\r",
81
- BACKSPACE = "\b"
81
+ BACKSPACE = "\b",
82
+ ALL = "a"
82
83
  }
83
84
  export declare type InteractiveCommandExecutionResult = {
84
85
  code: number | null;
package/lib/execCmd.js CHANGED
@@ -170,6 +170,7 @@ var Interaction;
170
170
  Interaction["Yes"] = "Y\r";
171
171
  Interaction["No"] = "N\r";
172
172
  Interaction["BACKSPACE"] = "\b";
173
+ Interaction["ALL"] = "a";
173
174
  })(Interaction = exports.Interaction || (exports.Interaction = {}));
174
175
  /**
175
176
  * Execute an interactive command.
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(`sfdx auth:jwt:grant -d -u ${kit_1.env.getString('TESTKIT_HUB_USERNAME', '')} -i ${kit_1.env.getString('TESTKIT_JWT_CLIENT_ID', '')} -f ${jwtKey} -r ${kit_1.env.getString('TESTKIT_HUB_INSTANCE', DEFAULT_INSTANCE_URL)}`, execOpts);
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
  }
@@ -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?;
@@ -94,6 +94,16 @@ class TestSession extends kit_1.AsyncOptionalCreatable {
94
94
  process.env.USERPROFILE = process.env.HOME = this.homeDir = kit_1.env.getString('TESTKIT_HOMEDIR', this.dir);
95
95
  process.env.SFDX_USE_GENERIC_UNIX_KEYCHAIN = 'true';
96
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
+ }
97
107
  }
98
108
  /**
99
109
  * Get an existing test session created with the same options,
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.3",
4
+ "version": "3.1.1",
5
5
  "author": "Salesforce",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "lib/index.js",