Skip to content

Commit

Permalink
fix: match library changes for deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Feb 23, 2021
1 parent e180b0d commit abba216
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 48 deletions.
28 changes: 14 additions & 14 deletions src/commands/force/source/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export class deploy extends SourceCommand {
checkonly: flags.boolean({
char: 'c',
description: messages.getMessage('flags.checkonly'),
default: false,
}),
wait: flags.minutes({
char: 'w',
Expand All @@ -48,12 +47,10 @@ export class deploy extends SourceCommand {
ignoreerrors: flags.boolean({
char: 'o',
description: messages.getMessage('flags.ignoreErrors'),
default: false,
}),
ignorewarnings: flags.boolean({
char: 'g',
description: messages.getMessage('flags.ignoreWarnings'),
default: false,
}),
validateddeployrequestid: flags.id({
char: 'q',
Expand Down Expand Up @@ -104,19 +101,22 @@ export class deploy extends SourceCommand {

await hookEmitter.emit('predeploy', { packageXmlPath: cs.getPackageXml() });

const results = await cs.deploy(this.org.getUsername(), {
wait: (this.flags.wait as Duration).milliseconds,
apiOptions: {
// TODO: build out more api options
checkOnly: this.flags.checkonly as boolean,
ignoreWarnings: this.flags.ignorewarnings as boolean,
runTests: this.flags.runtests as string[],
},
});

const results = await cs
.deploy({
usernameOrConnection: this.org.getUsername(),
apiOptions: {
checkOnly: this.flags.checkonly as boolean,
ignoreWarnings: this.flags.ignorewarnings as boolean,
runTests: this.flags.runtests as string[],
},
})
.start();
await hookEmitter.emit('postdeploy', results);

this.print(results);
// skip a lot of steps that would do nothing
if (!this.flags.json) {
this.print(results);
}

return results;
}
Expand Down
74 changes: 40 additions & 34 deletions src/commands/force/source/retrieve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import * as os from 'os';
import * as path from 'path';
// import * as path from 'path';
import { flags, FlagsConfig } from '@salesforce/command';
import { Lifecycle, Messages, SfdxError, SfdxProjectJson } from '@salesforce/core';
import { SourceRetrieveResult } from '@salesforce/source-deploy-retrieve';
// import { SourceRetrieveResult } from '@salesforce/source-deploy-retrieve';
import { Duration } from '@salesforce/kit';
import { asArray, asString } from '@salesforce/ts-types';
import { blue, yellow } from 'chalk';
// import { blue, yellow } from 'chalk';
import { SourceCommand } from '../../../sourceCommand';

Messages.importMessagesDirectory(__dirname);
Expand Down Expand Up @@ -51,7 +51,8 @@ export class retrieve extends SourceCommand {
};
protected readonly lifecycleEventNames = ['preretrieve', 'postretrieve'];

public async run(): Promise<SourceRetrieveResult> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
public async run(): Promise<any> {
const hookEmitter = Lifecycle.getInstance();

const proj = await SfdxProjectJson.create({});
Expand All @@ -70,20 +71,25 @@ export class retrieve extends SourceCommand {
// needs to be a path to the temp dir package.xml
await hookEmitter.emit('preretrieve', { packageXmlPath: cs.getPackageXml() });

const results = await cs.retrieve(this.org.getUsername(), path.resolve(defaultPackage.path), {
merge: true,
// TODO: fix this once wait has been updated in library
wait: (this.flags.wait as Duration).milliseconds,
// TODO: implement retrieve via package name
// package: options.packagenames
});
const mdapiResult = await cs
.retrieve({
usernameOrConnection: this.org.getUsername(),
merge: true,
output: (this.flags.sourcepath as string) ?? defaultPackage.path,
// TODO: fix this once wait has been updated in library
// wait: (this.flags.wait as Duration).milliseconds,
// TODO: implement retrieve via package name
// package: options.packagenames
})
.start();

const results = mdapiResult.response;
await hookEmitter.emit('postretrieve', results);

if (results.status === 'InProgress') {
throw new SfdxError(messages.getMessage('retrieveTimeout', [(this.flags.wait as Duration).minutes]));
}
this.printTable(results, true);
// this.printTable(results, true);

return results;
}
Expand All @@ -94,28 +100,28 @@ export class retrieve extends SourceCommand {
* @param results what the .deploy or .retrieve method returns
* @param withoutState a boolean to add state, default to true
*/
public printTable(results: SourceRetrieveResult, withoutState?: boolean): void {
const stateCol = withoutState ? [] : [{ key: 'state', label: messages.getMessage('stateTableColumn') }];
// public printTable(results: SourceRetrieveResult, withoutState?: boolean): void {
// const stateCol = withoutState ? [] : [{ key: 'state', label: messages.getMessage('stateTableColumn') }];

this.ux.styledHeader(blue(messages.getMessage('retrievedSourceHeader')));
if (results.success && results.successes.length) {
const columns = [
{ key: 'properties.fullName', label: messages.getMessage('fullNameTableColumn') },
{ key: 'properties.type', label: messages.getMessage('typeTableColumn') },
{
key: 'properties.fileName',
label: messages.getMessage('workspacePathTableColumn'),
},
];
this.ux.table(results.successes, { columns: [...stateCol, ...columns] });
} else {
this.ux.log(messages.getMessage('NoResultsFound'));
}
// this.ux.styledHeader(blue(messages.getMessage('retrievedSourceHeader')));
// if (results.success && results.successes.length) {
// const columns = [
// { key: 'properties.fullName', label: messages.getMessage('fullNameTableColumn') },
// { key: 'properties.type', label: messages.getMessage('typeTableColumn') },
// {
// key: 'properties.fileName',
// label: messages.getMessage('workspacePathTableColumn'),
// },
// ];
// this.ux.table(results.successes, { columns: [...stateCol, ...columns] });
// } else {
// this.ux.log(messages.getMessage('NoResultsFound'));
// }

if (results.status === 'PartialSuccess' && results.successes.length && results.failures.length) {
this.ux.log('');
this.ux.styledHeader(yellow(messages.getMessage('metadataNotFoundWarning')));
results.failures.forEach((warning) => this.ux.log(warning.message));
}
}
// if (results.status === 'PartialSuccess' && results.successes.length && results.failures.length) {
// this.ux.log('');
// this.ux.styledHeader(yellow(messages.getMessage('metadataNotFoundWarning')));
// results.failures.forEach((warning) => this.ux.log(warning.message));
// }
// }
}

0 comments on commit abba216

Please sign in to comment.