Skip to content

Commit

Permalink
fix: missing walkContent on delete prompt (#986)
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc authored Apr 22, 2024
1 parent 034e416 commit 415ad2d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/commands/project/delete/source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ export class Source extends SfCommand<DeleteSourceJson> {
// for custom labels, print each custom label to be deleted, not the whole file
isNonDecomposedCustomLabelsOrCustomLabel(c)
? [`${c.type.name}:${c.fullName}`]
: [c.xml as string, ...c.walkContent()] ?? []
: [c.xml, ...c.walkContent()] ?? []
)
.concat(this.mixedDeployDelete.delete.map((fr) => `${fr.fullName} (${fr.filePath})`));

Expand Down
2 changes: 1 addition & 1 deletion src/utils/previewOutput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const resolvePaths = (
return resolver.getComponentsFromPath(filename);
} catch (e) {
// resolver will do logging before throw we don't do it here
return undefined;
return [];
}
})
.filter(isSourceComponentWithXml)
Expand Down
8 changes: 6 additions & 2 deletions src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
SourceComponent,
FileResponseFailure,
FileResponseSuccess,
ComponentLike,
} from '@salesforce/source-deploy-retrieve';
import { isObject } from '@salesforce/ts-types';
import { DefaultReportOptions } from '@salesforce/apex-node';
Expand Down Expand Up @@ -89,18 +90,19 @@ export type Formatter<T> = {
};

/** validates source component with fullname, type, and xml props */
export const isSourceComponent = (sc: unknown): sc is SourceComponent =>
export const isSourceComponent = (sc: ComponentLike): sc is SourceComponent =>
isObject(sc) &&
'type' in sc &&
typeof sc.type === 'object' &&
sc.type !== null &&
'name' in sc.type &&
typeof sc.type.name === 'string' &&
'fullName' in sc &&
'walkContent' in sc &&
// (typeof sc.fullName === 'string' || typeof sc.fullName === 'function');
typeof sc.fullName === 'string';

export const isSourceComponentWithXml = (sc: unknown): sc is SourceComponent & { xml: string } =>
export const isSourceComponentWithXml = (sc: ComponentLike): sc is SourceComponent & { xml: string } =>
isSourceComponent(sc) && 'xml' in sc && typeof sc.xml === 'string';

export const isSdrFailure = (fileResponse: FileResponse): fileResponse is FileResponseFailure =>
Expand All @@ -111,3 +113,5 @@ export const isSdrSuccess = (fileResponse: FileResponse): fileResponse is FileRe

export const isFileResponseDeleted = (fileResponse: FileResponseSuccess): boolean =>
fileResponse.state === ComponentStatus.Deleted;

export const isDefined = <T>(value?: T): value is T => value !== undefined;
6 changes: 0 additions & 6 deletions test/utils/types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ const type = reg.getTypeByName('ApexClass');

describe('isSourceComponent (type guard)', () => {
describe('good', () => {
it('full, correct definition', () => {
expect({ fullName: 'foo', type, xml: 'fooXml', content: 'fooContent' }).to.satisfy(isSourceComponent);
});
it('SC constructed with xml', () => {
expect(new SourceComponent({ name: 'foo', type, xml: 'classes/foo.cls' })).to.satisfy(isSourceComponent);
});
Expand All @@ -45,9 +42,6 @@ describe('isSourceComponent (type guard)', () => {

describe('isSourceComponentWithXml (type guard)', () => {
describe('good', () => {
it('full, correct definition', () => {
expect({ fullName: 'foo', type, xml: 'fooXml', content: 'fooContent' }).to.satisfy(isSourceComponentWithXml);
});
it('SC constructed with xml', () => {
expect(new SourceComponent({ name: 'foo', type, xml: 'classes/foo.cls' })).to.satisfy(isSourceComponentWithXml);
});
Expand Down

0 comments on commit 415ad2d

Please sign in to comment.