@salesforce/cli-plugins-testkit 1.5.34 → 2.0.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/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  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.
4
4
 
5
+ ### [2.0.1](https://github.com/salesforcecli/cli-plugins-testkit/compare/v2.0.0...v2.0.1) (2022-06-01)
6
+
7
+ ## [2.0.0](https://github.com/salesforcecli/cli-plugins-testkit/compare/v1.5.35...v2.0.0) (2022-05-31)
8
+
9
+ ### Features
10
+
11
+ - parking orbit (core3, jsforce2) ([4575f9c](https://github.com/salesforcecli/cli-plugins-testkit/commit/4575f9c330528b1c6b4e6895ccde1fcd3b7d667e))
12
+
13
+ ### [1.5.35](https://github.com/salesforcecli/cli-plugins-testkit/compare/v1.5.34...v1.5.35) (2022-05-03)
14
+
5
15
  ### [1.5.34](https://github.com/salesforcecli/cli-plugins-testkit/compare/v1.5.33...v1.5.34) (2022-05-02)
6
16
 
7
17
  ### [1.5.33](https://github.com/salesforcecli/cli-plugins-testkit/compare/v1.5.32...v1.5.33) (2022-05-02)
package/lib/execCmd.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { SfdxError } from '@salesforce/core';
1
+ import { SfError } from '@salesforce/core';
2
2
  import { Duration } from '@salesforce/kit';
3
3
  import { AnyJson } from '@salesforce/ts-types';
4
4
  import { ExecOptions, ShellString } from 'shelljs';
@@ -45,7 +45,7 @@ export interface SfdxExecCmdResult<T = Collection> extends ExecCmdResult {
45
45
  jsonOutput?: {
46
46
  status: number;
47
47
  result: T;
48
- } & Partial<ExcludeMethods<SfdxError>>;
48
+ } & Partial<ExcludeMethods<SfError>>;
49
49
  }
50
50
  export interface SfExecCmdResult<T = Collection> extends ExecCmdResult {
51
51
  /**
@@ -54,7 +54,7 @@ export interface SfExecCmdResult<T = Collection> extends ExecCmdResult {
54
54
  jsonOutput?: {
55
55
  status: number;
56
56
  result: T;
57
- } & Partial<ExcludeMethods<SfdxError>>;
57
+ } & Partial<ExcludeMethods<SfError>>;
58
58
  }
59
59
  /**
60
60
  * Synchronously execute a command with the provided options in a child process.
package/lib/execCmd.js CHANGED
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.execCmd = void 0;
2
4
  /*
3
5
  * Copyright (c) 2021, salesforce.com, inc.
4
6
  * All rights reserved.
5
7
  * Licensed under the BSD 3-Clause license.
6
8
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7
9
  */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.execCmd = void 0;
10
+ const fs = require("fs");
10
11
  const path_1 = require("path");
11
12
  const util_1 = require("util");
12
- const core_1 = require("@salesforce/core");
13
13
  const kit_1 = require("@salesforce/kit");
14
14
  const ts_types_1 = require("@salesforce/ts-types");
15
15
  const debug_1 = require("debug");
@@ -55,21 +55,22 @@ const getExitCodeError = (cmd, expectedCode, output) => {
55
55
  *
56
56
  * The executable preference order is:
57
57
  * 2. TESTKIT_EXECUTABLE_PATH env var
58
- * 3. `bin/run` (default)
58
+ * 3. `bin/dev` (default)
59
59
  *
60
60
  * @param cmdArgs The command name, args, and param as a string. E.g., `"force:user:create -a testuser1"`
61
61
  * @returns The command string with CLI executable. E.g., `"node_modules/bin/sfdx force:user:create -a testuser1"`
62
62
  */
63
63
  const buildCmd = (cmdArgs, options) => {
64
+ var _a;
64
65
  const debug = (0, debug_1.default)('testkit:buildCmd');
65
- const bin = kit_1.env.getString('TESTKIT_EXECUTABLE_PATH') || (0, path_1.join)('bin', 'run');
66
+ const bin = (_a = kit_1.env.getString('TESTKIT_EXECUTABLE_PATH')) !== null && _a !== void 0 ? _a : (0, path_1.join)('bin', 'dev');
66
67
  const which = shelljs.which(bin);
67
68
  let resolvedPath = (0, path_1.resolve)(bin);
68
69
  // If which finds the path in the system path, use that.
69
70
  if (which) {
70
71
  resolvedPath = which;
71
72
  }
72
- else if (!core_1.fs.fileExistsSync(bin)) {
73
+ else if (!fs.existsSync(bin)) {
73
74
  throw new Error(`Cannot find specified executable path: ${bin}`);
74
75
  }
75
76
  debug(`Using executable path: ${bin}`);
package/lib/hubAuth.js CHANGED
@@ -9,9 +9,9 @@ exports.transferExistingAuthToEnv = exports.testkitHubAuth = exports.prepareForA
9
9
  */
10
10
  const path = require("path");
11
11
  const os = require("os");
12
+ const fs = require("fs");
12
13
  const shell = require("shelljs");
13
14
  const debug_1 = require("debug");
14
- const core_1 = require("@salesforce/core");
15
15
  const kit_1 = require("@salesforce/kit");
16
16
  // this seems to be a known eslint error for enums
17
17
  // eslint-disable-next-line no-shadow
@@ -53,13 +53,13 @@ const formatJwtKey = () => {
53
53
  };
54
54
  const prepareForJwt = (homeDir) => {
55
55
  const jwtKey = path.join(homeDir, 'jwtKey');
56
- core_1.fs.writeFileSync(jwtKey, formatJwtKey());
56
+ fs.writeFileSync(jwtKey, formatJwtKey());
57
57
  return jwtKey;
58
58
  };
59
59
  exports.prepareForJwt = prepareForJwt;
60
60
  const prepareForAuthUrl = (homeDir) => {
61
61
  const tmpUrl = path.join(homeDir, 'tmpUrl');
62
- core_1.fs.writeFileSync(tmpUrl, kit_1.env.getString('TESTKIT_AUTH_URL', ''));
62
+ fs.writeFileSync(tmpUrl, kit_1.env.getString('TESTKIT_AUTH_URL', ''));
63
63
  return tmpUrl;
64
64
  };
65
65
  exports.prepareForAuthUrl = prepareForAuthUrl;
@@ -140,11 +140,11 @@ const transferExistingAuthToEnv = (authStrategy = getAuthStrategy()) => {
140
140
  logger(`reading ${devhub}.json`);
141
141
  const authFileName = `${devhub}.json`;
142
142
  const hubAuthFileSource = path.join(kit_1.env.getString('HOME') || os.homedir(), '.sfdx', authFileName);
143
- const authFileContents = core_1.fs.readJsonSync(hubAuthFileSource);
143
+ const authFileContents = JSON.parse(fs.readFileSync(hubAuthFileSource, 'utf-8'));
144
144
  if (authFileContents.privateKey) {
145
145
  logger('copying variables to env from AuthFile for JWT');
146
146
  // this is jwt. set the appropriate env vars
147
- kit_1.env.setString('TESTKIT_JWT_KEY', core_1.fs.readFileSync(authFileContents.privateKey, 'utf-8'));
147
+ kit_1.env.setString('TESTKIT_JWT_KEY', fs.readFileSync(authFileContents.privateKey, 'utf-8'));
148
148
  kit_1.env.setString('TESTKIT_JWT_CLIENT_ID', authFileContents.clientId);
149
149
  kit_1.env.setString('TESTKIT_HUB_INSTANCE', authFileContents.instanceUrl);
150
150
  return;
@@ -1,18 +1,18 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TestProject = void 0;
2
4
  /*
3
5
  * Copyright (c) 2021, salesforce.com, inc.
4
6
  * All rights reserved.
5
7
  * Licensed under the BSD 3-Clause license.
6
8
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7
9
  */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.TestProject = void 0;
10
+ const fs = require("fs");
10
11
  const path = require("path");
11
12
  const os_1 = require("os");
12
13
  const util_1 = require("util");
13
14
  const debug_1 = require("debug");
14
15
  const shell = require("shelljs");
15
- const core_1 = require("@salesforce/core");
16
16
  const kit_1 = require("@salesforce/kit");
17
17
  const genUniqueString_1 = require("./genUniqueString");
18
18
  const zip_1 = require("./zip");
@@ -61,7 +61,7 @@ class TestProject {
61
61
  }
62
62
  // the git clone will fail if the destination dir is not empty, so after
63
63
  // a successful clone the only contents should be the cloned repo dir.
64
- const cloneDirName = core_1.fs.readdirSync(destDir)[0];
64
+ const cloneDirName = fs.readdirSync(destDir)[0];
65
65
  this.dir = path.join(destDir, cloneDirName);
66
66
  }
67
67
  // Create a new project using the command.
@@ -7,10 +7,9 @@ exports.TestSession = void 0;
7
7
  * Licensed under the BSD 3-Clause license.
8
8
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
9
9
  */
10
+ const fs = require("fs");
10
11
  const path = require("path");
11
- const ts_retry_promise_1 = require("ts-retry-promise");
12
12
  const debug_1 = require("debug");
13
- const core_1 = require("@salesforce/core");
14
13
  const kit_1 = require("@salesforce/kit");
15
14
  const ts_types_1 = require("@salesforce/ts-types");
16
15
  const sinon_1 = require("sinon");
@@ -69,7 +68,7 @@ class TestSession extends kit_1.AsyncOptionalCreatable {
69
68
  // Create the test session directory
70
69
  this.overriddenDir = kit_1.env.getString('TESTKIT_SESSION_DIR') || this.options.sessionDir;
71
70
  this.dir = this.overriddenDir || path.join(process.cwd(), `test_session_${this.id}`);
72
- core_1.fs.mkdirpSync(this.dir);
71
+ fs.mkdirSync(this.dir, { recursive: true });
73
72
  // Setup a test project and stub process.cwd to be the project dir
74
73
  if (this.options.project) {
75
74
  let projectDir = kit_1.env.getString('TESTKIT_PROJECT_DIR');
@@ -77,17 +76,18 @@ class TestSession extends kit_1.AsyncOptionalCreatable {
77
76
  this.project = new testProject_1.TestProject({ ...this.options.project, destinationDir: this.dir });
78
77
  projectDir = this.project.dir;
79
78
  }
80
- // The default bin/run in execCmd will no longer resolve properly when
79
+ // The default bin/dev in execCmd will no longer resolve properly when
81
80
  // a test project is used since process.cwd is changed. If the
82
81
  // TESTKIT_EXECUTABLE_PATH env var is not being used, then set it
83
- // to use the bin/run from the cwd now.
82
+ // to use the bin/dev from the cwd now.
84
83
  if (!kit_1.env.getString('TESTKIT_EXECUTABLE_PATH')) {
85
- kit_1.env.setString('TESTKIT_EXECUTABLE_PATH', path.join(process.cwd(), 'bin', 'run'));
84
+ const binDev = path.join(process.cwd(), 'bin', 'dev');
85
+ kit_1.env.setString('TESTKIT_EXECUTABLE_PATH', fs.existsSync(binDev) ? binDev : path.join(process.cwd(), 'bin', 'run'));
86
86
  }
87
87
  this.stubCwd(projectDir);
88
88
  }
89
89
  // Write the test session options used to create this session
90
- core_1.fs.writeJsonSync(path.join(this.dir, 'testSessionOptions.json'), JSON.parse(JSON.stringify(this.options)));
90
+ fs.writeFileSync(path.join(this.dir, 'testSessionOptions.json'), JSON.stringify(JSON.parse(JSON.stringify(this.options))));
91
91
  const authStrategy = this.options.authStrategy ? hubAuth_1.AuthStrategy[this.options.authStrategy] : undefined;
92
92
  // have to grab this before we change the home
93
93
  (0, hubAuth_1.transferExistingAuthToEnv)(authStrategy);
@@ -189,20 +189,8 @@ class TestSession extends kit_1.AsyncOptionalCreatable {
189
189
  if (this.overriddenDir) {
190
190
  return;
191
191
  }
192
- // this is wrapped in a promise because shelljs isn't async/await
193
- return await (0, ts_retry_promise_1.retry)(() => new Promise((resolve, reject) => {
194
- this.debug(`Deleting test session dir: ${this.dir}`);
195
- const rv = shell.rm('-rf', this.dir);
196
- if (rv.code !== 0) {
197
- reject(`Deleting the test session failed due to: ${rv.stderr}`);
198
- }
199
- resolve();
200
- }), this.rmRetryConfig).catch((err) => {
201
- if (err instanceof ts_retry_promise_1.RetryError) {
202
- throw err.lastError;
203
- }
204
- throw err;
205
- });
192
+ this.debug(`Deleting test session dir: ${this.dir}`);
193
+ return fs.promises.rm(this.dir, { recursive: true, force: true });
206
194
  }
207
195
  // Executes commands and keeps track of any orgs created.
208
196
  // Throws if any commands return a non-zero exitCode.
package/lib/zip.js CHANGED
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.zipDir = void 0;
2
4
  /*
3
5
  * Copyright (c) 2021, salesforce.com, inc.
4
6
  * All rights reserved.
5
7
  * Licensed under the BSD 3-Clause license.
6
8
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7
9
  */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.zipDir = void 0;
10
+ const fs = require("fs");
10
11
  const path = require("path");
11
12
  const archiver_1 = require("archiver");
12
13
  const debug_1 = require("debug");
13
- const core_1 = require("@salesforce/core");
14
14
  /**
15
15
  * Zip the contents of a directory to a file.
16
16
  *
@@ -22,7 +22,7 @@ const zipDir = async (config) => {
22
22
  const { sourceDir, destDir, name } = config;
23
23
  const zip = (0, archiver_1.create)('zip', { zlib: { level: 3 } });
24
24
  const zipFilePath = path.join(destDir, name);
25
- const output = core_1.fs.createWriteStream(zipFilePath);
25
+ const output = fs.createWriteStream(zipFilePath);
26
26
  debug(`Zipping contents of ${sourceDir} to ${zipFilePath}`);
27
27
  return new Promise((resolve, reject) => {
28
28
  output.on('close', () => {
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": "1.5.34",
4
+ "version": "2.0.1",
5
5
  "author": "Salesforce",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "lib/index.js",
@@ -42,7 +42,7 @@
42
42
  "!lib/**/*.map"
43
43
  ],
44
44
  "dependencies": {
45
- "@salesforce/core": "^2.24.0",
45
+ "@salesforce/core": "^3.19.1",
46
46
  "@salesforce/kit": "^1.5.13",
47
47
  "@salesforce/ts-types": "^1.5.17",
48
48
  "archiver": "^5.2.0",
@@ -58,9 +58,6 @@
58
58
  "@salesforce/ts-sinon": "^1.3.18",
59
59
  "@types/archiver": "^5.1.0",
60
60
  "@types/debug": "^4.1.5",
61
- "@types/graceful-fs": "^4.1.5",
62
- "@types/jsforce": "^1.9.29",
63
- "@types/mkdirp": "^1.0.1",
64
61
  "@types/shelljs": "^0.8.8",
65
62
  "@typescript-eslint/eslint-plugin": "^4.26.0",
66
63
  "@typescript-eslint/parser": "^4.26.0",