Skip to content

Commit

Permalink
Merge pull request #1820 from Accenture/task/1805-when-running-build-…
Browse files Browse the repository at this point in the history
…ask-user-if-deploy-folder-should-be-purged-before-builddefinition-is-executed

task/1805 move purge-deploy-folder logic up to handle multi-type templating
  • Loading branch information
JoernBerkefeld authored Nov 2, 2024
2 parents c53a992 + 557bbaf commit 88af279
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 27 deletions.
26 changes: 1 addition & 25 deletions lib/Builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,9 @@ saved
* @param {string} selectedType supported metadata type
* @param {string[]} nameArr name of the metadata
* @param {string[]} marketArr market localizations
* @param {boolean} [isPurgeDeployFolder] whether to purge the deploy folder
* @returns {Promise.<MultiMetadataTypeList>} -
*/
static async buildDefinition(
businessUnit,
selectedType,
nameArr,
marketArr,
isPurgeDeployFolder
) {
static async buildDefinition(businessUnit, selectedType, nameArr, marketArr) {
const properties = await config.getProperties();
if (!(await config.checkProperties(properties))) {
return null;
Expand All @@ -222,25 +215,8 @@ saved
}
const buObject = await Cli.getCredentialObject(properties, businessUnit);
if (buObject !== null) {
// standard deploy folder
const deployDir = File.normalizePath([
properties.directories.deploy,
buObject.credential,
buObject.businessUnit,
]);
const builder = new Builder(properties, buObject);

if (isPurgeDeployFolder && builder.targetDir.includes(deployDir)) {
// Clear output folder structure for selected sub-type
// only run this if the standard deploy folder is a target of buildDefinition (which technically could be changed)
await File.remove(
File.normalizePath([
properties.directories.deploy,
buObject.credential,
buObject.businessUnit,
])
);
}
return builder._buildDefinition(selectedType, nameArr, templateVariables);
}
}
Expand Down
15 changes: 13 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1326,15 +1326,26 @@ class Mcdev {
return;
}
}
// standard deploy folder
const buObject = await Cli.getCredentialObject(properties, businessUnit);
const deployDir = File.normalizePath([
properties.directories.deploy,
buObject.credential,
buObject.businessUnit,
]);
if (isPurgeDeployFolder) {
// Clear output folder structure for selected sub-type
// only run this if the standard deploy folder is a target of buildDefinition (which technically could be changed)
await File.remove(deployDir);
}
/** @type {MultiMetadataTypeList} */
const returnObj = {};
for (const type of Object.keys(selectedTypes)) {
const result = await Builder.buildDefinition(
businessUnit,
type,
selectedTypes[type],
marketArr,
isPurgeDeployFolder
marketArr
);
returnObj[type] = result[type];
}
Expand Down

0 comments on commit 88af279

Please sign in to comment.