@salesforce/cli-plugins-testkit 1.5.18 → 1.5.21
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 +6 -0
- package/lib/execCmd.js +10 -10
- package/lib/genUniqueString.js +2 -2
- package/lib/hubAuth.js +4 -4
- package/lib/testProject.js +4 -4
- package/lib/testSession.js +10 -10
- package/lib/zip.js +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
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
|
+
### [1.5.21](https://github.com/salesforcecli/cli-plugins-testkit/compare/v1.5.20...v1.5.21) (2022-04-01)
|
|
6
|
+
|
|
7
|
+
### [1.5.20](https://github.com/salesforcecli/cli-plugins-testkit/compare/v1.5.19...v1.5.20) (2022-03-03)
|
|
8
|
+
|
|
9
|
+
### [1.5.19](https://github.com/salesforcecli/cli-plugins-testkit/compare/v1.5.18...v1.5.19) (2022-03-03)
|
|
10
|
+
|
|
5
11
|
### [1.5.18](https://github.com/salesforcecli/cli-plugins-testkit/compare/v1.5.17...v1.5.18) (2022-03-02)
|
|
6
12
|
|
|
7
13
|
### [1.5.17](https://github.com/salesforcecli/cli-plugins-testkit/compare/v1.5.16...v1.5.17) (2022-03-02)
|
package/lib/execCmd.js
CHANGED
|
@@ -38,7 +38,7 @@ const hrtimeToMillisDuration = (hrTime) => kit_1.Duration.milliseconds(hrTime[0]
|
|
|
38
38
|
const addJsonOutput = (cmd, result) => {
|
|
39
39
|
if (cmd.includes('--json')) {
|
|
40
40
|
try {
|
|
41
|
-
result.jsonOutput = kit_1.parseJson(stripAnsi(result.shellOutput.stdout));
|
|
41
|
+
result.jsonOutput = (0, kit_1.parseJson)(stripAnsi(result.shellOutput.stdout));
|
|
42
42
|
}
|
|
43
43
|
catch (parseErr) {
|
|
44
44
|
result.jsonError = parseErr;
|
|
@@ -61,10 +61,10 @@ const getExitCodeError = (cmd, expectedCode, output) => {
|
|
|
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
|
-
const debug = debug_1.default('testkit:buildCmd');
|
|
65
|
-
const bin = kit_1.env.getString('TESTKIT_EXECUTABLE_PATH') || path_1.join('bin', 'run');
|
|
64
|
+
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
66
|
const which = shelljs.which(bin);
|
|
67
|
-
let resolvedPath = path_1.resolve(bin);
|
|
67
|
+
let resolvedPath = (0, path_1.resolve)(bin);
|
|
68
68
|
// If which finds the path in the system path, use that.
|
|
69
69
|
if (which) {
|
|
70
70
|
resolvedPath = which;
|
|
@@ -82,12 +82,12 @@ const buildCmd = (cmdArgs, options) => {
|
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
84
|
const execCmdSync = (cmd, options) => {
|
|
85
|
-
const debug = debug_1.default('testkit:execCmd');
|
|
85
|
+
const debug = (0, debug_1.default)('testkit:execCmd');
|
|
86
86
|
// Add on the bin path
|
|
87
87
|
cmd = buildCmd(cmd, options);
|
|
88
88
|
const cmdOptions = buildCmdOptions(options);
|
|
89
89
|
debug(`Running cmd: ${cmd}`);
|
|
90
|
-
debug(`Cmd options: ${util_1.inspect(cmdOptions)}`);
|
|
90
|
+
debug(`Cmd options: ${(0, util_1.inspect)(cmdOptions)}`);
|
|
91
91
|
const result = {
|
|
92
92
|
shellOutput: '',
|
|
93
93
|
execCmdDuration: kit_1.Duration.seconds(0),
|
|
@@ -99,23 +99,23 @@ const execCmdSync = (cmd, options) => {
|
|
|
99
99
|
result.shellOutput.stderr = stripAnsi(result.shellOutput.stderr);
|
|
100
100
|
result.execCmdDuration = hrtimeToMillisDuration(process.hrtime(startTime));
|
|
101
101
|
debug(`Command completed with exit code: ${result.shellOutput.code}`);
|
|
102
|
-
if (ts_types_1.isNumber(cmdOptions.ensureExitCode) && result.shellOutput.code !== cmdOptions.ensureExitCode) {
|
|
102
|
+
if ((0, ts_types_1.isNumber)(cmdOptions.ensureExitCode) && result.shellOutput.code !== cmdOptions.ensureExitCode) {
|
|
103
103
|
throw getExitCodeError(cmd, cmdOptions.ensureExitCode, result.shellOutput);
|
|
104
104
|
}
|
|
105
105
|
return addJsonOutput(cmd, result);
|
|
106
106
|
};
|
|
107
107
|
const execCmdAsync = async (cmd, options) => {
|
|
108
|
-
const debug = debug_1.default('testkit:execCmdAsync');
|
|
108
|
+
const debug = (0, debug_1.default)('testkit:execCmdAsync');
|
|
109
109
|
// Add on the bin path
|
|
110
110
|
cmd = buildCmd(cmd, options);
|
|
111
111
|
const resultPromise = new Promise((resolve, reject) => {
|
|
112
112
|
const cmdOptions = buildCmdOptions(options);
|
|
113
113
|
debug(`Running cmd: ${cmd}`);
|
|
114
|
-
debug(`Cmd options: ${util_1.inspect(cmdOptions)}`);
|
|
114
|
+
debug(`Cmd options: ${(0, util_1.inspect)(cmdOptions)}`);
|
|
115
115
|
const callback = (code, stdout, stderr) => {
|
|
116
116
|
const execCmdDuration = hrtimeToMillisDuration(process.hrtime(startTime));
|
|
117
117
|
debug(`Command completed with exit code: ${code}`);
|
|
118
|
-
if (ts_types_1.isNumber(cmdOptions.ensureExitCode) && code !== cmdOptions.ensureExitCode) {
|
|
118
|
+
if ((0, ts_types_1.isNumber)(cmdOptions.ensureExitCode) && code !== cmdOptions.ensureExitCode) {
|
|
119
119
|
const output = new shelljs_1.ShellString(stdout);
|
|
120
120
|
output.code = code;
|
|
121
121
|
output.stderr = stderr;
|
package/lib/genUniqueString.js
CHANGED
|
@@ -18,11 +18,11 @@ const util_1 = require("util");
|
|
|
18
18
|
* @returns {string}
|
|
19
19
|
*/
|
|
20
20
|
const genUniqueString = (template) => {
|
|
21
|
-
const uniqueString = crypto_1.randomBytes(8).toString('hex');
|
|
21
|
+
const uniqueString = (0, crypto_1.randomBytes)(8).toString('hex');
|
|
22
22
|
if (!template) {
|
|
23
23
|
return uniqueString;
|
|
24
24
|
}
|
|
25
|
-
return template.includes('%s') ? util_1.format(template, uniqueString) : `${template}${uniqueString}`;
|
|
25
|
+
return template.includes('%s') ? (0, util_1.format)(template, uniqueString) : `${template}${uniqueString}`;
|
|
26
26
|
};
|
|
27
27
|
exports.genUniqueString = genUniqueString;
|
|
28
28
|
//# sourceMappingURL=genUniqueString.js.map
|
package/lib/hubAuth.js
CHANGED
|
@@ -76,7 +76,7 @@ exports.prepareForAuthUrl = prepareForAuthUrl;
|
|
|
76
76
|
* required for AuthUrl: TESTKIT_AUTH_URL
|
|
77
77
|
*/
|
|
78
78
|
const testkitHubAuth = (homeDir, authStrategy = getAuthStrategy()) => {
|
|
79
|
-
const logger = debug_1.debug('testkit:authFromStubbedHome');
|
|
79
|
+
const logger = (0, debug_1.debug)('testkit:authFromStubbedHome');
|
|
80
80
|
const execOpts = { silent: true };
|
|
81
81
|
const shellOverride = kit_1.env.getString('TESTKIT_EXEC_SHELL');
|
|
82
82
|
if (shellOverride) {
|
|
@@ -84,7 +84,7 @@ const testkitHubAuth = (homeDir, authStrategy = getAuthStrategy()) => {
|
|
|
84
84
|
}
|
|
85
85
|
if (authStrategy === AuthStrategy.JWT) {
|
|
86
86
|
logger('trying jwt auth');
|
|
87
|
-
const jwtKey = exports.prepareForJwt(homeDir);
|
|
87
|
+
const jwtKey = (0, exports.prepareForJwt)(homeDir);
|
|
88
88
|
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);
|
|
89
89
|
if (results.code !== 0) {
|
|
90
90
|
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}`);
|
|
@@ -93,7 +93,7 @@ const testkitHubAuth = (homeDir, authStrategy = getAuthStrategy()) => {
|
|
|
93
93
|
}
|
|
94
94
|
if (authStrategy === AuthStrategy.AUTH_URL) {
|
|
95
95
|
logger('trying to authenticate with AuthUrl');
|
|
96
|
-
const tmpUrl = exports.prepareForAuthUrl(homeDir);
|
|
96
|
+
const tmpUrl = (0, exports.prepareForAuthUrl)(homeDir);
|
|
97
97
|
const shellOutput = shell.exec(`sfdx auth:sfdxurl:store -d -f ${tmpUrl}`, execOpts);
|
|
98
98
|
logger(shellOutput);
|
|
99
99
|
if (shellOutput.code !== 0) {
|
|
@@ -135,7 +135,7 @@ const transferExistingAuthToEnv = (authStrategy = getAuthStrategy()) => {
|
|
|
135
135
|
// nothing to do if the variables are already provided
|
|
136
136
|
if (authStrategy !== AuthStrategy.REUSE)
|
|
137
137
|
return;
|
|
138
|
-
const logger = debug_1.debug('testkit:AuthReuse');
|
|
138
|
+
const logger = (0, debug_1.debug)('testkit:AuthReuse');
|
|
139
139
|
const devhub = kit_1.env.getString('TESTKIT_HUB_USERNAME', '');
|
|
140
140
|
logger(`reading ${devhub}.json`);
|
|
141
141
|
const authFileName = `${devhub}.json`;
|
package/lib/testProject.js
CHANGED
|
@@ -30,11 +30,11 @@ class TestProject {
|
|
|
30
30
|
this.shelljsExecOptions = {
|
|
31
31
|
silent: true,
|
|
32
32
|
};
|
|
33
|
-
this.debug = debug_1.debug('testkit:project');
|
|
34
|
-
this.debug(`Creating TestProject with options: ${util_1.inspect(options)}`);
|
|
33
|
+
this.debug = (0, debug_1.debug)('testkit:project');
|
|
34
|
+
this.debug(`Creating TestProject with options: ${(0, util_1.inspect)(options)}`);
|
|
35
35
|
this.zipDir = zip_1.zipDir;
|
|
36
36
|
this.createdDate = new Date();
|
|
37
|
-
const destDir = options.destinationDir || os_1.tmpdir();
|
|
37
|
+
const destDir = options.destinationDir || (0, os_1.tmpdir)();
|
|
38
38
|
const shellOverride = kit_1.env.getString('TESTKIT_EXEC_SHELL');
|
|
39
39
|
if (shellOverride) {
|
|
40
40
|
this.shelljsExecOptions.shell = shellOverride;
|
|
@@ -70,7 +70,7 @@ class TestProject {
|
|
|
70
70
|
if (!shell.which('sfdx')) {
|
|
71
71
|
throw new Error('sfdx executable not found for creating a project using force:project:create command');
|
|
72
72
|
}
|
|
73
|
-
const name = options.name || genUniqueString_1.genUniqueString('project_%s');
|
|
73
|
+
const name = options.name || (0, genUniqueString_1.genUniqueString)('project_%s');
|
|
74
74
|
const rv = shell.exec(`sfdx force:project:create -n ${name} -d ${destDir}`, this.shelljsExecOptions);
|
|
75
75
|
if (rv.code !== 0) {
|
|
76
76
|
throw new Error(`force:project:create failed with error:\n${rv.stderr}`);
|
package/lib/testSession.js
CHANGED
|
@@ -51,16 +51,16 @@ class TestSession extends kit_1.AsyncOptionalCreatable {
|
|
|
51
51
|
super(options);
|
|
52
52
|
// this is stored on the class so that tests can set it to something much lower than default
|
|
53
53
|
this.rmRetryConfig = { retries: 12, delay: 5000 };
|
|
54
|
-
this.sandbox = sinon_1.createSandbox();
|
|
54
|
+
this.sandbox = (0, sinon_1.createSandbox)();
|
|
55
55
|
this.orgs = [];
|
|
56
56
|
this.shelljsExecOptions = {
|
|
57
57
|
silent: true,
|
|
58
58
|
};
|
|
59
59
|
this.options = options;
|
|
60
|
-
this.debug = debug_1.debug('testkit:session');
|
|
60
|
+
this.debug = (0, debug_1.debug)('testkit:session');
|
|
61
61
|
this.zipDir = zip_1.zipDir;
|
|
62
62
|
this.createdDate = new Date();
|
|
63
|
-
this.id = genUniqueString_1.genUniqueString(`${this.createdDate.valueOf()}%s`);
|
|
63
|
+
this.id = (0, genUniqueString_1.genUniqueString)(`${this.createdDate.valueOf()}%s`);
|
|
64
64
|
this.setupRetries = kit_1.env.getNumber('TESTKIT_SETUP_RETRIES', this.options.retries) || 0;
|
|
65
65
|
const shellOverride = kit_1.env.getString('TESTKIT_EXEC_SHELL');
|
|
66
66
|
if (shellOverride) {
|
|
@@ -90,11 +90,11 @@ class TestSession extends kit_1.AsyncOptionalCreatable {
|
|
|
90
90
|
core_1.fs.writeJsonSync(path.join(this.dir, 'testSessionOptions.json'), 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
|
-
hubAuth_1.transferExistingAuthToEnv(authStrategy);
|
|
93
|
+
(0, hubAuth_1.transferExistingAuthToEnv)(authStrategy);
|
|
94
94
|
// Set the homedir used by this test, on the TestSession and the process
|
|
95
95
|
process.env.USERPROFILE = process.env.HOME = this.homeDir = kit_1.env.getString('TESTKIT_HOMEDIR', this.dir);
|
|
96
96
|
process.env.SFDX_USE_GENERIC_UNIX_KEYCHAIN = 'true';
|
|
97
|
-
hubAuth_1.testkitHubAuth(this.homeDir, authStrategy);
|
|
97
|
+
(0, hubAuth_1.testkitHubAuth)(this.homeDir, authStrategy);
|
|
98
98
|
}
|
|
99
99
|
/**
|
|
100
100
|
* Get an existing test session created with the same options,
|
|
@@ -190,7 +190,7 @@ class TestSession extends kit_1.AsyncOptionalCreatable {
|
|
|
190
190
|
return;
|
|
191
191
|
}
|
|
192
192
|
// this is wrapped in a promise because shelljs isn't async/await
|
|
193
|
-
return await ts_retry_promise_1.retry(() => new Promise((resolve, reject) => {
|
|
193
|
+
return await (0, ts_retry_promise_1.retry)(() => new Promise((resolve, reject) => {
|
|
194
194
|
this.debug(`Deleting test session dir: ${this.dir}`);
|
|
195
195
|
const rv = shell.rm('-rf', this.dir);
|
|
196
196
|
if (rv.code !== 0) {
|
|
@@ -208,7 +208,7 @@ class TestSession extends kit_1.AsyncOptionalCreatable {
|
|
|
208
208
|
// Throws if any commands return a non-zero exitCode.
|
|
209
209
|
async setupCommands(cmds) {
|
|
210
210
|
var _a;
|
|
211
|
-
const dbug = debug_1.debug('testkit:setupCommands');
|
|
211
|
+
const dbug = (0, debug_1.debug)('testkit:setupCommands');
|
|
212
212
|
const setup = () => {
|
|
213
213
|
if (cmds) {
|
|
214
214
|
this.setup = [];
|
|
@@ -244,10 +244,10 @@ class TestSession extends kit_1.AsyncOptionalCreatable {
|
|
|
244
244
|
// Automatically parse json results
|
|
245
245
|
if (cmd.includes('--json')) {
|
|
246
246
|
try {
|
|
247
|
-
const jsonOutput = kit_1.parseJson(rv.stdout);
|
|
247
|
+
const jsonOutput = (0, kit_1.parseJson)(rv.stdout);
|
|
248
248
|
// keep track of all org creates
|
|
249
249
|
if (cmd.includes('org:create')) {
|
|
250
|
-
const username = ts_types_1.getString(jsonOutput, 'result.username');
|
|
250
|
+
const username = (0, ts_types_1.getString)(jsonOutput, 'result.username');
|
|
251
251
|
if (username) {
|
|
252
252
|
dbug(`Saving org username: ${username} from ${cmd}`);
|
|
253
253
|
this.orgs.push(username);
|
|
@@ -287,7 +287,7 @@ class TestSession extends kit_1.AsyncOptionalCreatable {
|
|
|
287
287
|
}
|
|
288
288
|
}
|
|
289
289
|
async sleep(duration) {
|
|
290
|
-
await kit_1.sleep(duration);
|
|
290
|
+
await (0, kit_1.sleep)(duration);
|
|
291
291
|
}
|
|
292
292
|
}
|
|
293
293
|
exports.TestSession = TestSession;
|
package/lib/zip.js
CHANGED
|
@@ -18,9 +18,9 @@ const core_1 = require("@salesforce/core");
|
|
|
18
18
|
* @returns The created zip file path
|
|
19
19
|
*/
|
|
20
20
|
const zipDir = async (config) => {
|
|
21
|
-
const debug = debug_1.default('testkit:zipDir');
|
|
21
|
+
const debug = (0, debug_1.default)('testkit:zipDir');
|
|
22
22
|
const { sourceDir, destDir, name } = config;
|
|
23
|
-
const zip = archiver_1.create('zip', { zlib: { level: 3 } });
|
|
23
|
+
const zip = (0, archiver_1.create)('zip', { zlib: { level: 3 } });
|
|
24
24
|
const zipFilePath = path.join(destDir, name);
|
|
25
25
|
const output = core_1.fs.createWriteStream(zipFilePath);
|
|
26
26
|
debug(`Zipping contents of ${sourceDir} to ${zipFilePath}`);
|
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.
|
|
4
|
+
"version": "1.5.21",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"main": "lib/index.js",
|