Skip to content

Commit cc06152

Browse files
#0 fix: build command prompts for deploy folder purge and passes mcdev flags
1 parent fc68734 commit cc06152

6 files changed

Lines changed: 90 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to the **SFMC DevTools** VS Code extension are documented in
44

55
Publishing is triggered automatically via GitHub Actions when a new release is created.
66

7+
## [3.1.1] — 2026-04-08
8+
9+
### Fixed
10+
11+
- **Build (Template + Definition)**: the command now asks whether to clear the deploy folder before building and passes `--purge` or `--no-purge` to mcdev so the CLI no longer waits indefinitely on an interactive prompt in the VS Code terminal.
12+
713
## [3.1.0] — 2026-04-08
814

915
### Added

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "sfmc-devtools-vscode",
33
"displayName": "SFMC DevTools",
44
"description": "Unofficial IDE for Salesforce Marketing Cloud - Handle and manipulate several SFMC assets (journeys, automations, queries, SSJS, AMPScript, etc..) between your local machine and Salesforce Marketing Cloud (SFMC).",
5-
"version": "3.1.0",
5+
"version": "3.1.1",
66
"license": "MIT",
77
"publisher": "Accenture-oss",
88
"repository": {

src/devtools/commands/templating.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ class TemplatingCommands extends Commands {
100100
if ("retrieve" in parameters && parameters.retrieve) optional.push("--retrieve");
101101
if ("skipValidation" in parameters && parameters.skipValidation)
102102
optional.push(this.retrieveFlag("skipValidation"));
103+
if (parameters.purge === true) optional.push(this.retrieveFlag("purge"));
104+
else optional.push(this.retrieveFlag("noPurge"));
103105
const buFromVal = parameters.buFrom as string;
104106
const buToVal = parameters.buTo as string;
105107
const marketFromVal = parameters.marketFrom as string;

src/devtools/index.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,8 @@ class DevToolsExtension {
10451045
}
10461046

10471047
/**
1048-
* Handles the build command by prompting the user for source/target BU and market selections.
1048+
* Handles the build command by prompting the user for source/target BU, markets, and whether
1049+
* to clear the deploy folder (maps to mcdev `--purge` / `--no-purge`).
10491050
*/
10501051
async handleBuildCommand(files: TDevTools.IExecuteFileDetails[]): Promise<void> {
10511052
try {
@@ -1081,12 +1082,20 @@ class DevToolsExtension {
10811082
| undefined;
10821083
if (!marketTo) return;
10831084

1085+
const purgeChoice = (await this.requestInputWithOptions(
1086+
[MessagesEditor.buildPurgeOptionYes, MessagesEditor.buildPurgeOptionNo],
1087+
MessagesEditor.buildPurgePrompt,
1088+
false
1089+
)) as string | undefined;
1090+
if (!purgeChoice) return;
1091+
10841092
this.executeCommand("build", {
10851093
filesDetails: supportedFiles,
10861094
buFrom: buFrom[0],
10871095
buTo: buTo[0],
10881096
marketFrom,
1089-
marketTo
1097+
marketTo,
1098+
purge: purgeChoice === MessagesEditor.buildPurgeOptionYes
10901099
});
10911100
} catch (error) {
10921101
this.writeLog(this.mcdev.getPackageName(), error as string, EnumsExtension.LoggerLevel.ERROR);

src/messages/editor.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ const noBusinessUnitsFound = (credential: string) =>
2727
`No business units were found for the selected credential: "${credential}". Please check the configuration file.`;
2828
const unsupportedAction = (action: string, metadataTypes: string[]) =>
2929
`The selected metadata type${metadataTypes.length > 1 ? "s do" : " does"} not support "${action}": ${metadataTypes.join(", ")}`;
30+
const buildPurgePrompt = "Clear deploy folder before building?";
31+
const buildPurgeOptionYes = "Yes, clear deploy folder before building";
32+
const buildPurgeOptionNo = "No, keep existing deploy folder";
3033

3134
export {
3235
recommendedExtensions,
@@ -46,5 +49,8 @@ export {
4649
noCredentialFound,
4750
deleteConfirmation,
4851
noBusinessUnitsFound,
49-
unsupportedAction
52+
unsupportedAction,
53+
buildPurgePrompt,
54+
buildPurgeOptionYes,
55+
buildPurgeOptionNo
5056
};

src/test/suite/devtools/templatingCommands.test.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,66 @@ suite("TemplatingCommands – clone", () => {
6464
assert.strictEqual(result.alias, "clone");
6565
});
6666
});
67+
68+
function makeBuildParams(purge?: boolean): TDevTools.ICommandParameters {
69+
const base = {
70+
files: [
71+
{
72+
credential: "",
73+
projectPath: "/project",
74+
topFolder: "/retrieve/",
75+
metadata: [{ metadatatype: "dataExtension", key: "myDE", path: "/retrieve/cred/bu/dataExtension" }]
76+
}
77+
],
78+
buFrom: "srcCred/srcBU",
79+
buTo: "tgtCred/tgtBU",
80+
marketFrom: "sourceMarket",
81+
marketTo: "targetMarket"
82+
};
83+
return purge === undefined ? base : { ...base, purge };
84+
}
85+
86+
suite("TemplatingCommands – build", () => {
87+
let cmd: TemplatingCommands;
88+
setup(() => {
89+
cmd = new TemplatingCommands();
90+
});
91+
92+
test("commandsList includes build", () => {
93+
assert.ok(cmd.commandsList().includes("build"));
94+
});
95+
96+
test("build with purge true includes --purge", () => {
97+
const result = cmd.build(makeBuildParams(true));
98+
const paramStr = result.config[0][0];
99+
assert.ok(paramStr.includes("--purge"));
100+
assert.ok(!paramStr.includes("--no-purge"));
101+
});
102+
103+
test("build with purge false includes --no-purge", () => {
104+
const result = cmd.build(makeBuildParams(false));
105+
const paramStr = result.config[0][0];
106+
assert.ok(paramStr.includes("--no-purge"));
107+
assert.ok(!/\s--purge(\s|$)/.test(paramStr));
108+
});
109+
110+
test("build without purge defaults to --no-purge", () => {
111+
const result = cmd.build(makeBuildParams());
112+
const paramStr = result.config[0][0];
113+
assert.ok(paramStr.includes("--no-purge"));
114+
});
115+
116+
test("build returns alias build", () => {
117+
const result = cmd.build(makeBuildParams(false));
118+
assert.strictEqual(result.alias, "build");
119+
});
120+
121+
test("run dispatches to build", () => {
122+
const result = cmd.run("build", makeBuildParams(true));
123+
assert.strictEqual(result.alias, "build");
124+
});
125+
126+
test("build throws when required properties missing", () => {
127+
assert.throws(() => cmd.build({ files: [] }), /\[templating_build\]/);
128+
});
129+
});

0 commit comments

Comments
 (0)