@salesforce/cli-plugins-testkit 3.2.0 → 3.2.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/hubAuth.js +1 -1
- package/lib/testProject.js +2 -2
- package/lib/testSession.js +8 -3
- package/package.json +12 -18
package/lib/hubAuth.js
CHANGED
|
@@ -131,7 +131,7 @@ const transferExistingAuthToEnv = (authStrategy) => {
|
|
|
131
131
|
const devhub = kit_1.env.getString('TESTKIT_HUB_USERNAME', '');
|
|
132
132
|
logger(`reading ${devhub}.json`);
|
|
133
133
|
const authFileName = `${devhub}.json`;
|
|
134
|
-
const hubAuthFileSource = path.join(kit_1.env.getString('HOME')
|
|
134
|
+
const hubAuthFileSource = path.join(kit_1.env.getString('HOME') ?? os.homedir(), '.sfdx', authFileName);
|
|
135
135
|
const authFileContents = JSON.parse(fs.readFileSync(hubAuthFileSource, 'utf-8'));
|
|
136
136
|
if (authFileContents.privateKey) {
|
|
137
137
|
logger('copying variables to env from AuthFile for JWT');
|
package/lib/testProject.js
CHANGED
|
@@ -34,7 +34,7 @@ class TestProject {
|
|
|
34
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
|
|
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
|
|
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
|
@@ -60,14 +60,14 @@ class TestSession extends kit_1.AsyncOptionalCreatable {
|
|
|
60
60
|
this.zipDir = zip_1.zipDir;
|
|
61
61
|
this.createdDate = new Date();
|
|
62
62
|
this.id = (0, genUniqueString_1.genUniqueString)(`${this.createdDate.valueOf()}%s`);
|
|
63
|
-
this.retries = kit_1.env.getNumber('TESTKIT_SETUP_RETRIES', this.options.retries)
|
|
63
|
+
this.retries = kit_1.env.getNumber('TESTKIT_SETUP_RETRIES', this.options.retries) ?? 0;
|
|
64
64
|
const shellOverride = kit_1.env.getString('TESTKIT_EXEC_SHELL');
|
|
65
65
|
if (shellOverride) {
|
|
66
66
|
this.shelljsExecOptions.shell = shellOverride;
|
|
67
67
|
}
|
|
68
68
|
// Create the test session directory
|
|
69
|
-
this.overriddenDir = kit_1.env.getString('TESTKIT_SESSION_DIR')
|
|
70
|
-
this.dir = this.overriddenDir
|
|
69
|
+
this.overriddenDir = kit_1.env.getString('TESTKIT_SESSION_DIR') ?? this.options.sessionDir;
|
|
70
|
+
this.dir = this.overriddenDir ?? path.join(process.cwd(), `test_session_${this.id}`);
|
|
71
71
|
fs.mkdirSync(this.dir, { recursive: true });
|
|
72
72
|
// Setup a test project and stub process.cwd to be the project dir
|
|
73
73
|
if (this.options.project) {
|
|
@@ -185,6 +185,7 @@ class TestSession extends kit_1.AsyncOptionalCreatable {
|
|
|
185
185
|
this.orgs.delete(org);
|
|
186
186
|
if (rv.code !== 0) {
|
|
187
187
|
// Must still delete the session dir if org:delete fails
|
|
188
|
+
// eslint-disable-next-line no-await-in-loop
|
|
188
189
|
await this.rmSessionDir();
|
|
189
190
|
throw Error(`Deleting org ${org} failed due to: ${rv.stderr}`);
|
|
190
191
|
}
|
|
@@ -282,11 +283,15 @@ class TestSession extends kit_1.AsyncOptionalCreatable {
|
|
|
282
283
|
throw err;
|
|
283
284
|
}
|
|
284
285
|
dbug(`Setup failed. waiting ${timeout.seconds} seconds before next attempt...`);
|
|
286
|
+
// eslint-disable-next-line no-await-in-loop
|
|
285
287
|
await this.deleteOrgs();
|
|
288
|
+
// eslint-disable-next-line no-await-in-loop
|
|
286
289
|
await this.sleep(timeout);
|
|
287
290
|
}
|
|
288
291
|
}
|
|
289
292
|
}
|
|
293
|
+
// used for test spy/stub
|
|
294
|
+
// eslint-disable-next-line class-methods-use-this
|
|
290
295
|
async sleep(duration) {
|
|
291
296
|
await (0, kit_1.sleep)(duration);
|
|
292
297
|
}
|
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.2.
|
|
4
|
+
"version": "3.2.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": "^3.30.
|
|
45
|
+
"@salesforce/core": "^3.30.12",
|
|
46
46
|
"@salesforce/kit": "^1.6.1",
|
|
47
47
|
"@salesforce/ts-types": "^1.5.21",
|
|
48
48
|
"@types/shelljs": "^0.8.11",
|
|
@@ -54,38 +54,32 @@
|
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@salesforce/dev-config": "^3.0.0",
|
|
57
|
-
"@salesforce/dev-scripts": "^
|
|
57
|
+
"@salesforce/dev-scripts": "^3.1.0",
|
|
58
58
|
"@salesforce/prettier-config": "^0.0.2",
|
|
59
59
|
"@salesforce/ts-sinon": "^1.4.0",
|
|
60
60
|
"@types/archiver": "^5.1.0",
|
|
61
61
|
"@types/debug": "^4.1.5",
|
|
62
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
63
|
-
"@typescript-eslint/parser": "^
|
|
62
|
+
"@typescript-eslint/eslint-plugin": "^5.39.0",
|
|
63
|
+
"@typescript-eslint/parser": "^5.39.0",
|
|
64
64
|
"chai": "^4.3.0",
|
|
65
|
-
"
|
|
66
|
-
"eslint": "^
|
|
67
|
-
"eslint-config-
|
|
68
|
-
"eslint-config-salesforce": "^0.1.6",
|
|
65
|
+
"eslint": "^8.21.0",
|
|
66
|
+
"eslint-config-prettier": "^8.5.0",
|
|
67
|
+
"eslint-config-salesforce": "^1.1.0",
|
|
69
68
|
"eslint-config-salesforce-license": "^0.1.6",
|
|
70
|
-
"eslint-config-salesforce-typescript": "^
|
|
69
|
+
"eslint-config-salesforce-typescript": "^1.1.1",
|
|
71
70
|
"eslint-plugin-header": "^3.1.1",
|
|
72
71
|
"eslint-plugin-import": "2.26.0",
|
|
73
|
-
"eslint-plugin-jsdoc": "^
|
|
74
|
-
"eslint-plugin-prettier": "^3.4.0",
|
|
72
|
+
"eslint-plugin-jsdoc": "^39.3.6",
|
|
75
73
|
"husky": "^7.0.4",
|
|
76
74
|
"mocha": "^9.1.3",
|
|
77
75
|
"nyc": "^15.1.0",
|
|
78
|
-
"prettier": "^2.
|
|
76
|
+
"prettier": "^2.7.1",
|
|
79
77
|
"pretty-quick": "^3.1.0",
|
|
80
78
|
"sinon": "10.0.0",
|
|
81
79
|
"ts-node": "^10.0.0",
|
|
82
80
|
"typescript": "^4.8.4"
|
|
83
81
|
},
|
|
84
|
-
"config": {
|
|
85
|
-
"commitizen": {
|
|
86
|
-
"path": "cz-conventional-changelog"
|
|
87
|
-
}
|
|
88
|
-
},
|
|
82
|
+
"config": {},
|
|
89
83
|
"publishConfig": {
|
|
90
84
|
"access": "public"
|
|
91
85
|
}
|