Skip to content

Commit 9e42923

Browse files
chore: update to match library api [skip-validate-pr]
1 parent ca11a46 commit 9e42923

File tree

4 files changed

+83
-89
lines changed

4 files changed

+83
-89
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"@oclif/config": "^1",
99
"@salesforce/command": "^3.1.0",
1010
"@salesforce/core": "^2.19.1",
11-
"@salesforce/source-deploy-retrieve": "^1.1.17",
11+
"@salesforce/source-deploy-retrieve": "^1.1.19",
1212
"chalk": "^4.1.0",
1313
"tslib": "^2"
1414
},

src/commands/force/source/deploy.ts

Lines changed: 42 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as os from 'os';
88
import * as path from 'path';
99
import { flags, FlagsConfig } from '@salesforce/command';
1010
import { Lifecycle, Messages } from '@salesforce/core';
11-
import { SourceDeployResult } from '@salesforce/source-deploy-retrieve';
11+
import { DeployResult } from '@salesforce/source-deploy-retrieve';
1212
import { Duration } from '@salesforce/kit';
1313
import { asString, asArray } from '@salesforce/ts-types';
1414
import * as chalk from 'chalk';
@@ -87,7 +87,7 @@ export class deploy extends SourceCommand {
8787
};
8888
protected readonly lifecycleEventNames = ['predeploy', 'postdeploy'];
8989

90-
public async run(): Promise<SourceDeployResult> {
90+
public async run(): Promise<DeployResult> {
9191
if (this.flags.validatedeployrequestid) {
9292
// TODO: return this.doDeployRecentValidation();
9393
}
@@ -104,11 +104,6 @@ export class deploy extends SourceCommand {
104104
const results = await cs
105105
.deploy({
106106
usernameOrConnection: this.org.getUsername(),
107-
apiOptions: {
108-
checkOnly: this.flags.checkonly as boolean,
109-
ignoreWarnings: this.flags.ignorewarnings as boolean,
110-
runTests: this.flags.runtests as string[],
111-
},
112107
})
113108
.start();
114109
await hookEmitter.emit('postdeploy', results);
@@ -121,71 +116,67 @@ export class deploy extends SourceCommand {
121116
return results;
122117
}
123118

124-
private printComponentFailures(result: SourceDeployResult): void {
125-
if (result.status === 'Failed' && result.components) {
119+
private printComponentFailures(result: DeployResult): void {
120+
if (result.response.status === 'Failed' && result.components) {
126121
// sort by filename then fullname
127-
const failures = result.components.sort((i, j) => {
128-
if (i.component.type.directoryName === j.component.type.directoryName) {
122+
const failures = result.getFileResponses().sort((i, j) => {
123+
if (i.filePath === j.filePath) {
129124
// if the have the same directoryName then sort by fullName
130-
return i.component.fullName < j.component.fullName ? 1 : -1;
125+
return i.fullName < j.fullName ? 1 : -1;
131126
}
132-
return i.component.type.directoryName < j.component.type.directoryName ? 1 : -1;
127+
return i.filePath < j.filePath ? 1 : -1;
133128
});
134129
this.ux.log('');
135130
this.ux.styledHeader(chalk.red(`Component Failures [${failures.length}]`));
136131
this.ux.table(failures, {
137-
// TODO: these accessors are temporary until library JSON fixes
138132
columns: [
139-
{ key: 'component.type.name', label: 'Type' },
140-
{ key: 'diagnostics[0].filePath', label: 'File' },
141-
{ key: 'component.name', label: 'Name' },
142-
{ key: 'diagnostics[0].message', label: 'Problem' },
133+
{ key: 'componentType', label: 'Type' },
134+
{ key: 'fileName', label: 'File' },
135+
{ key: 'fullName', label: 'Name' },
136+
{ key: 'problem', label: 'Problem' },
143137
],
144138
});
145139
this.ux.log('');
146140
}
147141
}
148142

149-
private printComponentSuccess(result: SourceDeployResult): void {
150-
if (result.success && result.components) {
151-
if (result.components.length > 0) {
152-
// sort by type then filename then fullname
153-
const files = result.components.sort((i, j) => {
154-
if (i.component.type.name === j.component.type.name) {
155-
// same metadata type, according to above comment sort on filename
156-
if (i.component.type.directoryName === j.component.type.directoryName) {
157-
// same filename's according to comment sort by fullName
158-
return i.component.fullName < j.component.fullName ? 1 : -1;
159-
}
160-
return i.component.type.directoryName < j.component.type.directoryName ? 1 : -1;
143+
private printComponentSuccess(result: DeployResult): void {
144+
if (result.response.success && result.components?.size) {
145+
// sort by type then filename then fullname
146+
const files = result.getFileResponses().sort((i, j) => {
147+
if (i.fullName === j.fullName) {
148+
// same metadata type, according to above comment sort on filename
149+
if (i.filePath === j.filePath) {
150+
// same filename's according to comment sort by fullName
151+
return i.fullName < j.fullName ? 1 : -1;
161152
}
162-
return i.component.type.name < j.component.type.name ? 1 : -1;
163-
});
164-
// get relative path for table output
165-
files.forEach((file) => {
166-
if (file.component.content) {
167-
file.component.content = path.relative(process.cwd(), file.component.content);
168-
}
169-
});
170-
this.ux.log('');
171-
this.ux.styledHeader(chalk.blue('Deployed Source'));
172-
this.ux.table(files, {
173-
// TODO: these accessors are temporary until library JSON fixes
174-
columns: [
175-
{ key: 'component.name', label: 'FULL NAME' },
176-
{ key: 'component.type.name', label: 'TYPE' },
177-
{ key: 'component.content', label: 'PROJECT PATH' },
178-
],
179-
});
180-
}
153+
return i.filePath < j.filePath ? 1 : -1;
154+
}
155+
return i.type < j.type ? 1 : -1;
156+
});
157+
// get relative path for table output
158+
files.forEach((file) => {
159+
if (file.filePath) {
160+
file.filePath = path.relative(process.cwd(), file.filePath);
161+
}
162+
});
163+
this.ux.log('');
164+
this.ux.styledHeader(chalk.blue('Deployed Source'));
165+
this.ux.table(files, {
166+
columns: [
167+
{ key: 'fullName', label: 'FULL NAME' },
168+
{ key: 'type', label: 'TYPE' },
169+
{ key: 'filePath', label: 'PROJECT PATH' },
170+
],
171+
});
181172
}
182173
}
183174

184-
private print(result: SourceDeployResult): SourceDeployResult {
175+
private print(result: DeployResult): DeployResult {
185176
this.printComponentSuccess(result);
186177
this.printComponentFailures(result);
187178
// TODO: this.printTestResults(result); <- this has WI @W-8903671@
188-
if (result.success && this.flags.checkonly) {
179+
if (result.response.success && this.flags.checkonly) {
189180
this.log(messages.getMessage('checkOnlySuccess'));
190181
}
191182

src/commands/force/source/retrieve.ts

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77
import * as os from 'os';
8-
// import * as path from 'path';
8+
99
import { flags, FlagsConfig } from '@salesforce/command';
1010
import { Lifecycle, Messages, SfdxError, SfdxProjectJson } from '@salesforce/core';
11-
// import { SourceRetrieveResult } from '@salesforce/source-deploy-retrieve';
1211
import { Duration } from '@salesforce/kit';
1312
import { asArray, asString } from '@salesforce/ts-types';
14-
// import { blue, yellow } from 'chalk';
13+
import { blue } from 'chalk';
14+
import { MetadataApiRetrieveStatus } from '@salesforce/source-deploy-retrieve';
15+
import { FileProperties } from '@salesforce/source-deploy-retrieve/lib/src/client/types';
1516
import { SourceCommand } from '../../../sourceCommand';
1617

1718
Messages.importMessagesDirectory(__dirname);
@@ -86,8 +87,12 @@ export class retrieve extends SourceCommand {
8687
if (results.status === 'InProgress') {
8788
throw new SfdxError(messages.getMessage('retrieveTimeout', [(this.flags.wait as Duration).minutes]));
8889
}
89-
this.ux.logJson(mdapiResult.getFileResponses());
90-
// this.printTable(results, true);
90+
91+
if (this.flags.json) {
92+
this.ux.logJson(mdapiResult.getFileResponses());
93+
} else {
94+
this.printTable(results, true);
95+
}
9196

9297
return results;
9398
}
@@ -98,28 +103,25 @@ export class retrieve extends SourceCommand {
98103
* @param results what the .deploy or .retrieve method returns
99104
* @param withoutState a boolean to add state, default to true
100105
*/
101-
// public printTable(results: SourceRetrieveResult, withoutState?: boolean): void {
102-
// const stateCol = withoutState ? [] : [{ key: 'state', label: messages.getMessage('stateTableColumn') }];
106+
public printTable(results: MetadataApiRetrieveStatus, withoutState?: boolean): void {
107+
const stateCol = withoutState ? [] : [{ key: 'state', label: 'STATE' }];
103108

104-
// this.ux.styledHeader(blue(messages.getMessage('retrievedSourceHeader')));
105-
// if (results.success && results.successes.length) {
106-
// const columns = [
107-
// { key: 'properties.fullName', label: messages.getMessage('fullNameTableColumn') },
108-
// { key: 'properties.type', label: messages.getMessage('typeTableColumn') },
109-
// {
110-
// key: 'properties.fileName',
111-
// label: messages.getMessage('workspacePathTableColumn'),
112-
// },
113-
// ];
114-
// this.ux.table(results.successes, { columns: [...stateCol, ...columns] });
115-
// } else {
116-
// this.ux.log(messages.getMessage('NoResultsFound'));
117-
// }
109+
this.ux.styledHeader(blue(messages.getMessage('retrievedSourceHeader')));
110+
if (results.success) {
111+
const columns = [
112+
{ key: 'fullName', label: 'FULL NAME' },
113+
{ key: 'type', label: 'TYPE' },
114+
{ key: 'fileName', label: 'PROJECT PATH' },
115+
];
116+
this.ux.table(results.fileProperties as FileProperties[], { columns: [...stateCol, ...columns] });
117+
} else {
118+
this.ux.log(messages.getMessage('NoResultsFound'));
119+
}
118120

119-
// if (results.status === 'PartialSuccess' && results.successes.length && results.failures.length) {
120-
// this.ux.log('');
121-
// this.ux.styledHeader(yellow(messages.getMessage('metadataNotFoundWarning')));
122-
// results.failures.forEach((warning) => this.ux.log(warning.message));
123-
// }
124-
// }
121+
// if (results.status === 'SucceededPartial' && results.successes.length && results.failures.length) {
122+
// this.ux.log('');
123+
// this.ux.styledHeader(yellow(messages.getMessage('metadataNotFoundWarning')));
124+
// results.failures.forEach((warning) => this.ux.log(warning.message));
125+
// }
126+
}
125127
}

yarn.lock

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -667,18 +667,18 @@
667667
resolved "https://registry.yarnpkg.com/@salesforce/schemas/-/schemas-1.0.3.tgz#4fcc42ad9241365d2050803eaadad3c431910aa8"
668668
integrity sha512-ND9JF3yAZQMIK51uC8RHN5w7NYLivTlcTaH2Udw51oyKlzeWUTYwtsNe534t+zPBSo98+mVJwk53WwEsEUe8iw==
669669

670-
"@salesforce/source-deploy-retrieve@^1.1.17":
671-
version "1.1.17"
672-
resolved "https://registry.yarnpkg.com/@salesforce/source-deploy-retrieve/-/source-deploy-retrieve-1.1.17.tgz#cec01cc4ce6cf6c9f0f66b295dd0475ab8006a63"
673-
integrity sha512-/n25cv3V6ouoF6+bdwrsAP/qHDPiAAsdho0OIyaPZJ58ymNTDkvg02qTeAu3onf6+6L6e1Bqzk46dRn1BoKExg==
670+
"@salesforce/source-deploy-retrieve@^1.1.19":
671+
version "1.1.19"
672+
resolved "https://registry.yarnpkg.com/@salesforce/source-deploy-retrieve/-/source-deploy-retrieve-1.1.19.tgz#6a184367dc74d15b073c010fa54096889f8a10c0"
673+
integrity sha512-IFTpHnhSaGbVjLDBI+oEO8yxTWE91+Eoj2dlYYn1ORgFuyd6/7f/h5LNbpqjDb/4XvJ4SQ+iy924mB3Yd6QPdg==
674674
dependencies:
675675
"@salesforce/core" "2.13.0"
676676
archiver "4.0.1"
677677
fast-xml-parser "^3.17.4"
678678
gitignore-parser "0.0.2"
679679
ignore "^5.1.8"
680680
mime "2.4.6"
681-
unzipper "0.10.0"
681+
unzipper "0.10.11"
682682
xmldom-sfdx-encoding "^0.1.29"
683683

684684
"@salesforce/[email protected]":
@@ -3181,7 +3181,7 @@ globby@^11.0.1:
31813181
merge2 "^1.3.0"
31823182
slash "^3.0.0"
31833183

3184-
graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.4:
3184+
graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.2, graceful-fs@^4.2.4:
31853185
version "4.2.6"
31863186
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.6.tgz#ff040b2b0853b23c3d31027523706f1885d76bee"
31873187
integrity sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==
@@ -6522,17 +6522,18 @@ unset-value@^1.0.0:
65226522
has-value "^0.3.1"
65236523
isobject "^3.0.0"
65246524

6525-
6526-
version "0.10.0"
6527-
resolved "https://registry.yarnpkg.com/unzipper/-/unzipper-0.10.0.tgz#99e0d2755de4d15fac6ad04a9cb6c1fcfc7c3e4c"
6528-
integrity sha512-Vi1fHl+isVKXAiDloz8ykI+DJ9pIzDFhwxbd6ceC8XltYQfoKPhswX3yRsccXnA8tP8LPAxZO1bVWVtGE/VHaQ==
6525+
6526+
version "0.10.11"
6527+
resolved "https://registry.yarnpkg.com/unzipper/-/unzipper-0.10.11.tgz#0b4991446472cbdb92ee7403909f26c2419c782e"
6528+
integrity sha512-+BrAq2oFqWod5IESRjL3S8baohbevGcVA+teAIOYWM3pDVdseogqbzhhvvmiyQrUNKFUnDMtELW3X8ykbyDCJw==
65296529
dependencies:
65306530
big-integer "^1.6.17"
65316531
binary "~0.3.0"
65326532
bluebird "~3.4.1"
65336533
buffer-indexof-polyfill "~1.0.0"
65346534
duplexer2 "~0.1.4"
65356535
fstream "^1.0.12"
6536+
graceful-fs "^4.2.2"
65366537
listenercount "~1.0.1"
65376538
readable-stream "~2.3.6"
65386539
setimmediate "~1.0.4"

0 commit comments

Comments
 (0)