Skip to content

Commit dacba93

Browse files
fix: add warinng message for AAB cascade delete
1 parent 3e848a1 commit dacba93

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

messages/delete.source.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ This operation will delete the following metadata in your org:
125125
This operation will deploy the following:
126126
%s
127127

128+
# cascadeDeleteWarning
129+
130+
Deleting components of type "%s" may cause the org to also delete the following related metadata (cascade delete): %s.
131+
128132
# areYouSure
129133

130134
Are you sure you want to proceed?

src/commands/project/delete/source.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,27 @@ Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
5959
const messages = Messages.loadMessages('@salesforce/plugin-deploy-retrieve', 'delete.source');
6060
const xorFlags = ['metadata', 'source-dir'];
6161

62+
/**
63+
* Metadata types that trigger cascade deletion in the org.
64+
*/
65+
const CASCADE_DELETE_TYPES: Record<string, string[]> = {
66+
AiAuthoringBundle: ['Bot, BotVersion, GenAiPlannerBundle'],
67+
};
68+
69+
/**
70+
* Returns warning messages for components that trigger cascade deletion in the org.
71+
*/
72+
const getCascadeDeleteWarnings = (typesBeingDeleted: Set<string>): string[] => {
73+
const warnings: string[] = [];
74+
for (const typeName of typesBeingDeleted) {
75+
const cascadeTypes = CASCADE_DELETE_TYPES[typeName];
76+
if (cascadeTypes?.length) {
77+
warnings.push(messages.getMessage('cascadeDeleteWarning', [typeName, cascadeTypes.join(', ')]));
78+
}
79+
}
80+
return warnings;
81+
};
82+
6283
type MixedDeployDelete = { deploy: string[]; delete: FileResponseSuccess[] };
6384
export class Source extends SfCommand<DeleteSourceJson> {
6485
public static readonly summary = messages.getMessage('summary');
@@ -459,6 +480,9 @@ Update the .forceignore file and try again.`);
459480
)
460481
.concat(this.mixedDeployDelete.delete.map((fr) => `${fr.fullName} (${fr.filePath})`));
461482

483+
const typesBeingDeleted = new Set((this.components ?? []).map((comp) => comp.type.name));
484+
const cascadeWarnings = getCascadeDeleteWarnings(typesBeingDeleted);
485+
462486
const message: string[] = [
463487
...(this.mixedDeployDelete.deploy.length
464488
? [messages.getMessage('deployPrompt', [[...new Set(this.mixedDeployDelete.deploy)].join('\n')])]
@@ -470,6 +494,8 @@ Update the .forceignore file and try again.`);
470494
...(local.length && (this.mixedDeployDelete.deploy.length || remote.length) ? ['\n'] : []),
471495
...(local.length ? [messages.getMessage('localPrompt', [[...new Set(local)].join('\n')])] : []),
472496

497+
...(cascadeWarnings.length ? [...cascadeWarnings] : []),
498+
473499
this.flags['check-only'] ?? false
474500
? messages.getMessage('areYouSureCheckOnly')
475501
: messages.getMessage('areYouSure'),

0 commit comments

Comments
 (0)