Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: missing walkContent on delete prompt #986

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading