Skip to content

Commit ee1bd7e

Browse files
feat: core7, jsforce-node
note: this still has some old jsforce because of apex-node. * chore: updates from devScripts * test: top-level imports * refactor: type handling for setError when class * test: schemas * fix: preserve error.context --------- Co-authored-by: mshanemc <shane.mclaughlin@salesforce.com>
1 parent dcad4be commit ee1bd7e

24 files changed

+312
-170
lines changed

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
"author": "Salesforce",
66
"bugs": "https://github.com/forcedotcom/cli/issues",
77
"dependencies": {
8-
"@oclif/core": "^3.25.2",
8+
"@oclif/core": "^3.26.2",
99
"@salesforce/apex-node": "^4.0.2",
10-
"@salesforce/core": "^6.4.4",
11-
"@salesforce/kit": "^3.0.15",
12-
"@salesforce/sf-plugins-core": "^8.0.3",
13-
"@salesforce/source-deploy-retrieve": "^10.5.5",
14-
"@salesforce/source-tracking": "^5.1.11",
10+
"@salesforce/core": "^7.0.1",
11+
"@salesforce/kit": "^3.1.0",
12+
"@salesforce/sf-plugins-core": "^9.0.1",
13+
"@salesforce/source-deploy-retrieve": "^11.0.0",
14+
"@salesforce/source-tracking": "^6.0.0",
1515
"@salesforce/ts-types": "^2.0.9",
1616
"chalk": "^5.3.0",
1717
"got": "^13.0.0",
@@ -20,16 +20,16 @@
2020
"devDependencies": {
2121
"@oclif/plugin-command-snapshot": "^5.1.4",
2222
"@oclif/plugin-help": "^6.0.20",
23-
"@salesforce/cli-plugins-testkit": "^5.1.9",
24-
"@salesforce/dev-scripts": "^8.5.0",
23+
"@salesforce/cli-plugins-testkit": "^5.2.0",
24+
"@salesforce/dev-scripts": "^9.0.0",
2525
"@salesforce/plugin-command-reference": "^3.0.70",
2626
"@salesforce/source-testkit": "^2.1.109",
2727
"@salesforce/ts-sinon": "1.4.19",
2828
"@types/archiver": "^5.3.2",
2929
"archiver": "^5.3.2",
3030
"chai-each": "^0.0.1",
3131
"cross-env": "^7.0.3",
32-
"eslint-plugin-sf-plugin": "^1.17.5",
32+
"eslint-plugin-sf-plugin": "^1.18.0",
3333
"fast-glob": "^3.3.1",
3434
"oclif": "^4.7.6",
3535
"ts-node": "^10.9.2",

schemas/force-source-deploy-cancel.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
},
88
"MetadataApiDeployStatus": {
99
"type": "object",
10+
"additionalProperties": false,
1011
"properties": {
1112
"id": {
1213
"type": "string"
@@ -108,7 +109,6 @@
108109
"status",
109110
"success"
110111
],
111-
"additionalProperties": false,
112112
"description": "Raw response returned from a checkDeployStatus call to the Metadata API"
113113
},
114114
"RequestStatus": {
@@ -154,8 +154,7 @@
154154
"type": "object",
155155
"properties": {
156156
"changed": {
157-
"type": ["string", "boolean"],
158-
"enum": ["true", "false", true, false]
157+
"$ref": "#/definitions/BooleanString"
159158
},
160159
"columnNumber": {
161160
"type": "string"
@@ -164,15 +163,13 @@
164163
"type": "string"
165164
},
166165
"created": {
167-
"type": ["string", "boolean"],
168-
"enum": ["true", "false", true, false]
166+
"$ref": "#/definitions/BooleanString"
169167
},
170168
"createdDate": {
171169
"type": "string"
172170
},
173171
"deleted": {
174-
"type": ["string", "boolean"],
175-
"enum": ["true", "false", true, false]
172+
"$ref": "#/definitions/BooleanString"
176173
},
177174
"fileName": {
178175
"type": "string"
@@ -194,13 +191,16 @@
194191
"enum": ["Warning", "Error"]
195192
},
196193
"success": {
197-
"type": ["string", "boolean"],
198-
"enum": ["true", "false", true, false]
194+
"$ref": "#/definitions/BooleanString"
199195
}
200196
},
201197
"required": ["changed", "created", "createdDate", "deleted", "fileName", "fullName", "success"],
202198
"additionalProperties": false
203199
},
200+
"BooleanString": {
201+
"type": ["string", "boolean"],
202+
"enum": ["true", "false", true, false]
203+
},
204204
"RunTestResult": {
205205
"type": "object",
206206
"properties": {

schemas/force-source-deploy-report.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
},
88
"MetadataApiDeployStatus": {
99
"type": "object",
10+
"additionalProperties": false,
1011
"properties": {
1112
"id": {
1213
"type": "string"
@@ -108,7 +109,6 @@
108109
"status",
109110
"success"
110111
],
111-
"additionalProperties": false,
112112
"description": "Raw response returned from a checkDeployStatus call to the Metadata API"
113113
},
114114
"RequestStatus": {
@@ -154,8 +154,7 @@
154154
"type": "object",
155155
"properties": {
156156
"changed": {
157-
"type": ["string", "boolean"],
158-
"enum": ["true", "false", true, false]
157+
"$ref": "#/definitions/BooleanString"
159158
},
160159
"columnNumber": {
161160
"type": "string"
@@ -164,15 +163,13 @@
164163
"type": "string"
165164
},
166165
"created": {
167-
"type": ["string", "boolean"],
168-
"enum": ["true", "false", true, false]
166+
"$ref": "#/definitions/BooleanString"
169167
},
170168
"createdDate": {
171169
"type": "string"
172170
},
173171
"deleted": {
174-
"type": ["string", "boolean"],
175-
"enum": ["true", "false", true, false]
172+
"$ref": "#/definitions/BooleanString"
176173
},
177174
"fileName": {
178175
"type": "string"
@@ -194,13 +191,16 @@
194191
"enum": ["Warning", "Error"]
195192
},
196193
"success": {
197-
"type": ["string", "boolean"],
198-
"enum": ["true", "false", true, false]
194+
"$ref": "#/definitions/BooleanString"
199195
}
200196
},
201197
"required": ["changed", "created", "createdDate", "deleted", "fileName", "fullName", "success"],
202198
"additionalProperties": false
203199
},
200+
"BooleanString": {
201+
"type": ["string", "boolean"],
202+
"enum": ["true", "false", true, false]
203+
},
204204
"RunTestResult": {
205205
"type": "object",
206206
"properties": {

schemas/force-source-deploy.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,7 @@
208208
"type": "object",
209209
"properties": {
210210
"changed": {
211-
"type": ["string", "boolean"],
212-
"enum": ["true", "false", true, false]
211+
"$ref": "#/definitions/BooleanString"
213212
},
214213
"columnNumber": {
215214
"type": "string"
@@ -218,15 +217,13 @@
218217
"type": "string"
219218
},
220219
"created": {
221-
"type": ["string", "boolean"],
222-
"enum": ["true", "false", true, false]
220+
"$ref": "#/definitions/BooleanString"
223221
},
224222
"createdDate": {
225223
"type": "string"
226224
},
227225
"deleted": {
228-
"type": ["string", "boolean"],
229-
"enum": ["true", "false", true, false]
226+
"$ref": "#/definitions/BooleanString"
230227
},
231228
"fileName": {
232229
"type": "string"
@@ -248,13 +245,16 @@
248245
"enum": ["Warning", "Error"]
249246
},
250247
"success": {
251-
"type": ["string", "boolean"],
252-
"enum": ["true", "false", true, false]
248+
"$ref": "#/definitions/BooleanString"
253249
}
254250
},
255251
"required": ["changed", "created", "createdDate", "deleted", "fileName", "fullName", "success"],
256252
"additionalProperties": false
257253
},
254+
"BooleanString": {
255+
"type": ["string", "boolean"],
256+
"enum": ["true", "false", true, false]
257+
},
258258
"RunTestResult": {
259259
"type": "object",
260260
"properties": {
@@ -459,6 +459,7 @@
459459
},
460460
"FileResponseSuccess": {
461461
"type": "object",
462+
"additionalProperties": false,
462463
"properties": {
463464
"fullName": {
464465
"type": "string"
@@ -474,11 +475,11 @@
474475
"enum": ["Created", "Changed", "Unchanged", "Deleted"]
475476
}
476477
},
477-
"required": ["fullName", "state", "type"],
478-
"additionalProperties": false
478+
"required": ["fullName", "state", "type"]
479479
},
480480
"FileResponseFailure": {
481481
"type": "object",
482+
"additionalProperties": false,
482483
"properties": {
483484
"fullName": {
484485
"type": "string"
@@ -507,11 +508,11 @@
507508
"enum": ["Warning", "Error"]
508509
}
509510
},
510-
"required": ["error", "fullName", "problemType", "state", "type"],
511-
"additionalProperties": false
511+
"required": ["error", "fullName", "problemType", "state", "type"]
512512
},
513513
"MetadataApiDeployStatus": {
514514
"type": "object",
515+
"additionalProperties": false,
515516
"properties": {
516517
"id": {
517518
"type": "string"
@@ -613,11 +614,11 @@
613614
"status",
614615
"success"
615616
],
616-
"additionalProperties": false,
617617
"description": "Raw response returned from a checkDeployStatus call to the Metadata API"
618618
},
619619
"DeployCommandAsyncResult": {
620620
"type": "object",
621+
"additionalProperties": false,
621622
"properties": {
622623
"done": {
623624
"type": "boolean"
@@ -649,8 +650,7 @@
649650
}
650651
}
651652
},
652-
"required": ["deploys", "done", "id", "outboundFiles", "state", "status", "timedOut"],
653-
"additionalProperties": false
653+
"required": ["deploys", "done", "id", "outboundFiles", "state", "status", "timedOut"]
654654
},
655655
"DeployAsyncStatus": {
656656
"type": "object",

schemas/force-source-retrieve.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
},
4343
"FileResponseSuccess": {
4444
"type": "object",
45+
"additionalProperties": false,
4546
"properties": {
4647
"fullName": {
4748
"type": "string"
@@ -57,11 +58,11 @@
5758
"enum": ["Created", "Changed", "Unchanged", "Deleted"]
5859
}
5960
},
60-
"required": ["fullName", "state", "type"],
61-
"additionalProperties": false
61+
"required": ["fullName", "state", "type"]
6262
},
6363
"FileResponseFailure": {
6464
"type": "object",
65+
"additionalProperties": false,
6566
"properties": {
6667
"fullName": {
6768
"type": "string"
@@ -90,8 +91,7 @@
9091
"enum": ["Warning", "Error"]
9192
}
9293
},
93-
"required": ["error", "fullName", "problemType", "state", "type"],
94-
"additionalProperties": false
94+
"required": ["error", "fullName", "problemType", "state", "type"]
9595
},
9696
"PackageRetrieval": {
9797
"type": "object",

src/formatters/mdapi/mdDeployResultFormatter.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import chalk from 'chalk';
9-
import { getNumber } from '@salesforce/ts-types';
9+
import { AnyJson, getNumber } from '@salesforce/ts-types';
1010
import { Messages, SfError } from '@salesforce/core';
1111
import {
1212
DeployMessage,
@@ -103,11 +103,13 @@ export class MdDeployResultFormatter extends ResultFormatter {
103103
}
104104
// TODO: the toolbelt version of this is returning an SfError shape. This returns a status=1 and the result (mdapi response) but not the error name, etc
105105
if (!this.isSuccess()) {
106-
// Add error message directly on the DeployResult (e.g., a GACK)
107-
const errMsg = this.getResponse()?.errorMessage ?? '';
108-
const error = new SfError(messages.getMessage('deployFailed', [errMsg]), 'mdapiDeployFailed');
109-
error.setData(this.result);
110-
throw error;
106+
throw SfError.create({
107+
// Add error message directly on the DeployResult (e.g., a GACK)
108+
message: messages.getMessage('deployFailed', [this.getResponse()?.errorMessage ?? '']),
109+
name: 'mdapiDeployFailed',
110+
// this.result is a Class, so here's the serializable portions of it
111+
data: JSON.parse(JSON.stringify(this.result)) as AnyJson,
112+
});
111113
}
112114
}
113115

src/formatters/source/pushResultFormatter.ts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,28 @@ export class PushResultFormatter extends ResultFormatter {
5555
public getJson(): PushResponse {
5656
// throws a particular json structure.
5757
if (process.exitCode !== 0) {
58+
const errorData = this.fileResponses.filter((fileResponse) => fileResponse.state === ComponentStatus.Failed);
59+
60+
const error = SfError.create({
61+
context: 'Push',
62+
name: 'DeployFailed',
63+
exitCode: process.exitCode,
64+
message: messages.getMessage('sourcepushFailed', ['']),
65+
data: errorData,
66+
});
67+
// matching toolbelt error json. Does not match the SfError type
68+
5869
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
5970
// @ts-ignore
60-
const error: SfError & {
61-
result: FileResponse[];
62-
commandName: string;
63-
context: string;
64-
partialSuccess: FileResponse[];
65-
} = new SfError(messages.getMessage('sourcepushFailed', ['']), 'DeployFailed', [], process.exitCode);
66-
const errorData = this.fileResponses.filter((fileResponse) => fileResponse.state === ComponentStatus.Failed);
67-
error.setData(errorData);
68-
error['result'] = errorData;
69-
error['commandName'] = 'Push';
70-
error['context'] = 'Push';
71+
error.result = errorData;
72+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
73+
// @ts-ignore
74+
error.commandName = 'Push';
75+
7176
// partial success
7277
if (process.exitCode === 69) {
78+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
79+
// @ts-ignore
7380
error['partialSuccess'] = this.fileResponses.filter(
7481
(fileResponse) => fileResponse.state !== ComponentStatus.Failed
7582
);

test/commands/mdapi/cancel.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { expect } from 'chai';
1111
import { spyMethod, stubMethod } from '@salesforce/ts-sinon';
1212
import { ConfigFile } from '@salesforce/core';
1313
import { MetadataApiDeploy } from '@salesforce/source-deploy-retrieve';
14-
import { MockTestOrgData, TestContext } from '@salesforce/core/lib/testSetup.js';
14+
import { MockTestOrgData, TestContext } from '@salesforce/core/testSetup';
1515
import { stubSfCommandUx, stubUx } from '@salesforce/sf-plugins-core';
1616
import { Cancel } from '../../../src/commands/force/mdapi/deploy/cancel.js';
1717
import { DeployCancelResultFormatter } from '../../../src/formatters/deployCancelResultFormatter.js';

test/commands/mdapi/retrieve.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { Config } from '@oclif/core';
1515
import { ComponentSetBuilder, ComponentSetOptions, RetrieveOptions } from '@salesforce/source-deploy-retrieve';
1616
import { Duration } from '@salesforce/kit';
1717
import { SfCommand, Ux } from '@salesforce/sf-plugins-core';
18-
import { MockTestOrgData, TestContext } from '@salesforce/core/lib/testSetup.js';
18+
import { MockTestOrgData, TestContext } from '@salesforce/core/testSetup';
1919
import { Retrieve } from '../../../src/commands/force/mdapi/retrieve.js';
2020
import { Stash, StashData } from '../../../src/stash.js';
2121
import { getRetrieveResult } from '../source/retrieveResponses.js';

test/commands/mdapi/retrieveReport.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { Config } from '@oclif/core';
1414

1515
import { MetadataApiRetrieve } from '@salesforce/source-deploy-retrieve';
1616
import { SfCommand, Ux } from '@salesforce/sf-plugins-core';
17-
import { MockTestOrgData, TestContext } from '@salesforce/core/lib/testSetup.js';
17+
import { MockTestOrgData, TestContext } from '@salesforce/core/testSetup';
1818

1919
import { Report } from '../../../src/commands/force/mdapi/retrieve/report.js';
2020
import { Stash } from '../../../src/stash.js';

0 commit comments

Comments
 (0)