Skip to content

Commit

Permalink
Merge pull request #514 from Accenture/develop
Browse files Browse the repository at this point in the history
4.1.8
  • Loading branch information
JoernBerkefeld authored Nov 6, 2022
2 parents 8096208 + 9694336 commit 335ec9d
Show file tree
Hide file tree
Showing 21 changed files with 200 additions and 170 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ body:
label: Version
description: What version of our software are you running? (mcdev --version)
options:
- 4.1.8
- 4.1.7
- 4.1.6
- 4.1.5
Expand Down
139 changes: 70 additions & 69 deletions README.md

Large diffs are not rendered by default.

68 changes: 34 additions & 34 deletions docs/dist/documentation.md

Large diffs are not rendered by default.

46 changes: 27 additions & 19 deletions lib/Deployer.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class Deployer {
return buMultiMetadataTypeMap;
}
/**
* helper for deploy()
* helper for {@link deploy}
*
* @param {string} cred name of Credential
* @param {string} bu name of BU
Expand Down Expand Up @@ -325,6 +325,7 @@ class Deployer {
static async createFolderDefinitions(deployDir, metadata, metadataTypeArr) {
let i = 0;
const folderMetadata = {};
const allowedDeFolderContentTypes = ['dataextension', 'shared_dataextension'];
for (const metadataType of metadataTypeArr) {
if (!MetadataTypeInfo[metadataType].definition.dependencies.includes('folder')) {
Util.logger.debug(` ☇ skipping ${metadataType}: folder not a dependency`);
Expand All @@ -346,23 +347,20 @@ class Deployer {
}
Util.logger.debug(`Creating relevant folders for ${metadataType} in deploy dir`);

let allFolders = Object.keys(metadata[metadataType]).filter(
// filter out root folders (which would not have a slash in their path)
(key) => metadata[metadataType][key].r__folder_Path.includes('/')
);
/* eslint-disable unicorn/prefer-ternary */
if (metadataType === 'dataExtension') {
allFolders = allFolders
.filter(
// filter out any shared / synchronized / salesforce folders
(key) =>
metadata[metadataType][key].r__folder_ContentType === 'dataextension'
)
.map((key) => metadata[metadataType][key].r__folder_Path);
} else {
allFolders = allFolders.map((key) => metadata[metadataType][key].r__folder_Path);
}
/* eslint-enable unicorn/prefer-ternary */
const allFolders = Object.keys(metadata[metadataType])
.filter(
// filter out root folders (which would not have a slash in their path)
(key) => metadata[metadataType][key].r__folder_Path.includes('/')
)
.filter(
// filter out dataExtension folders other than standard & shared (--> synchronized / salesforce are not allowed)
(key) =>
metadataType !== 'dataExtension' ||
allowedDeFolderContentTypes.includes(
metadata[metadataType][key].r__folder_ContentType
)
)
.map((key) => metadata[metadataType][key].r__folder_Path);

// deduplicate
const folderPathSet = new Set(allFolders);
Expand All @@ -384,21 +382,31 @@ class Deployer {

for (const folder of folderPathArrExtended) {
i++;
let contentType = MetadataTypeInfo[metadataType].definition.folderType;
if (
metadataType === 'dataExtension' &&
folder.startsWith('Shared Items/Shared Data Extensions')
) {
contentType = 'shared_dataextension';
}
folderMetadata[`on-the-fly-${i}`] = {
Path: folder,
Name: folder.split('/').pop(),
Description: '',
ContentType: MetadataTypeInfo[metadataType].definition.folderType,
ContentType: contentType,
IsActive: true,
IsEditable: true,
AllowChildren: true,
_generated: true,
};
}
}

if (i > 0) {
MetadataTypeInfo.folder.definition.fields._generated.retrieving = true; // ensure we keep that flag in deploy folder
// await results to allow us to re-read it right after
await MetadataTypeInfo.folder.saveResults(folderMetadata, deployDir, null);
MetadataTypeInfo.folder.definition.fields._generated.retrieving = false; // reset flag
Util.logger.info(`Created folders in deploy dir: ${i}`);

// reload from file system to ensure we use the same logic for building the temporary JSON
Expand Down
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class Mcdev {
}
}
/**
* helper for retrieve()
* helper for {@link retrieve}
*
* @private
* @param {string} cred name of Credential
Expand Down
16 changes: 8 additions & 8 deletions lib/metadataTypes/Asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class Asset extends MetadataType {
return { metadata: Object.values(metadata)[0], type: this.definition.type };
}
/**
* helper for retrieve + retrieveAsTemplate
* helper for {@link retrieve} + {@link retrieveAsTemplate}
*
* @private
* @returns {TYPE.AssetSubType[]} subtype array
Expand Down Expand Up @@ -443,7 +443,7 @@ class Asset extends MetadataType {
);
}
/**
* helper for this.preDeployTasks()
* helper for {@link preDeployTasks}
* Some metadata types store their actual content as a separate file, e.g. images
* This method reads these from the local FS stores them in the metadata object allowing to deploy it
*
Expand Down Expand Up @@ -607,7 +607,7 @@ class Asset extends MetadataType {
}
}
/**
* helper for buildDefinition
* helper for {@link MetadataType.buildDefinition}
* handles extracted code if any are found for complex types
*
* @param {string} templateDir Directory where metadata templates are stored
Expand All @@ -634,7 +634,7 @@ class Asset extends MetadataType {
);
}
/**
* helper for buildTemplate
* helper for {@link MetadataType.buildTemplate}
* handles extracted code if any are found for complex types
*
* @example assets of type codesnippetblock will result in 1 json and 1 amp/html file. both files need to be run through templating
Expand Down Expand Up @@ -663,7 +663,7 @@ class Asset extends MetadataType {
}

/**
* helper for buildDefinition
* helper for {@link MetadataType.buildDefinition}
* handles extracted code if any are found for complex types
*
* @param {string} templateDir Directory where metadata templates are stored
Expand Down Expand Up @@ -792,7 +792,7 @@ class Asset extends MetadataType {
return metadata;
}
/**
* helper for this.preDeployTasks() that loads extracted code content back into JSON
* helper for {@link preDeployTasks} that loads extracted code content back into JSON
*
* @param {TYPE.AssetItem} metadata a single asset definition
* @param {string} deployDir directory of deploy files
Expand Down Expand Up @@ -1024,7 +1024,7 @@ class Asset extends MetadataType {
return fileList;
}
/**
* helper for this.preDeployTasks() that loads extracted code content back into JSON
* helper for {@link preDeployTasks} that loads extracted code content back into JSON
*
* @param {string} prefix usually the customerkey
* @param {object} metadataSlots metadata.views.html.slots or deeper slots.<>.blocks.<>.slots
Expand Down Expand Up @@ -1104,7 +1104,7 @@ class Asset extends MetadataType {
}
}
/**
* helper for this.parseMetadata() that finds code content in JSON and extracts it
* helper for {@link parseMetadata} that finds code content in JSON and extracts it
* to allow saving that separately and formatted
*
* @param {TYPE.AssetItem} metadata a single asset definition
Expand Down
2 changes: 1 addition & 1 deletion lib/metadataTypes/DataExtension.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class DataExtension extends MetadataType {
}

/**
* helper for upsert()
* helper for {@link upsert}
*
* @param {object} res -
* @returns {boolean} true: keep, false: discard
Expand Down
2 changes: 1 addition & 1 deletion lib/metadataTypes/DataExtensionField.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class DataExtensionField extends MetadataType {
return super.retrieveSOAP(null, null, requestParams, additionalFields);
}
/**
* helper for DataExtension.js that sorts the fields into an array
* helper for {@link DataExtension._retrieveFieldsForSingleDe} that sorts the fields into an array
*
* @param {TYPE.DataExtensionFieldMap} fieldsObj customerKey-based list of fields for one dataExtension
* @returns {TYPE.DataExtensionFieldItem[]} sorted array of field objects
Expand Down
44 changes: 29 additions & 15 deletions lib/metadataTypes/Folder.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ class Folder extends MetadataType {
*/
static async upsert(metadata) {
let updateCount = 0;
let updateFailedCount = 0;
let createCount = 0;
let createFailedCount = 0;
let filteredByPreDeploy = 0;
const upsertResults = {};
const sortPairs = toposort(
Expand Down Expand Up @@ -206,12 +208,13 @@ class Folder extends MetadataType {
);
if (
existingId &&
!this.hasChangedGeneric(
cachedVersion,
metadata[metadataKey],
null,
true
)
(metadata[metadataKey]._generated || // of generated, never "update"
!this.hasChangedGeneric(
cachedVersion,
metadata[metadataKey],
'Path',
true
))
) {
Util.logger.verbose(
` - skipping ${this.definition.type} ${
Expand All @@ -228,12 +231,13 @@ class Folder extends MetadataType {
existingId = cachedVersion?.ID;
if (
existingId &&
!this.hasChangedGeneric(
cachedVersion,
metadata[metadataKey],
null,
true
)
(metadata[metadataKey]._generated || // of generated, never "update"
!this.hasChangedGeneric(
cachedVersion,
metadata[metadataKey],
'Path',
true
))
) {
Util.logger.verbose(
` - skipping ${this.definition.type} ${
Expand All @@ -253,10 +257,18 @@ class Folder extends MetadataType {
// if an existing folder exists with the same name/path then use that
deployableMetadata.ID = existingId;
result = await this.update(deployableMetadata);
updateCount++;
if (result) {
updateCount++;
} else {
updateFailedCount++;
}
} else {
result = await this.create(deployableMetadata);
createCount++;
if (result) {
createCount++;
} else {
createFailedCount++;
}
}
if (result?.Results) {
const parsed = this.parseResponseBody({
Expand Down Expand Up @@ -293,7 +305,9 @@ class Folder extends MetadataType {
}
// Logging
Util.logger.info(
`${this.definition.type} upsert: ${createCount} created / ${updateCount} updated` +
`${this.definition.type} upsert: ${createCount} of ${
createCount + createFailedCount
} created / ${updateCount} of ${updateCount + updateFailedCount} updated` +
(filteredByPreDeploy > 0 ? ` / ${filteredByPreDeploy} filtered` : '')
);

Expand Down
8 changes: 4 additions & 4 deletions lib/metadataTypes/MetadataType.js
Original file line number Diff line number Diff line change
Expand Up @@ -1281,7 +1281,7 @@ class MetadataType {
return savedResults;
}
/**
* helper for buildDefinitionForNested
* helper for {@link buildDefinitionForNested}
* searches extracted file for template variable names and applies the market values
*
* @param {string} code code from extracted code
Expand All @@ -1293,7 +1293,7 @@ class MetadataType {
return Mustache.render(code, templateVariables);
}
/**
* helper for buildTemplateForNested
* helper for {@link buildTemplateForNested}
* searches extracted file for template variable values and applies the market variable names
*
* @param {string} code code from extracted code
Expand All @@ -1305,7 +1305,7 @@ class MetadataType {
return Util.replaceByObject(code, templateVariables);
}
/**
* helper for buildDefinition
* helper for {@link buildDefinition}
* handles extracted code if any are found for complex types (e.g script, asset, query)
*
* @param {string} templateDir Directory where metadata templates are stored
Expand All @@ -1326,7 +1326,7 @@ class MetadataType {
return null;
}
/**
* helper for buildTemplate
* helper for {@link buildTemplate}
* handles extracted code if any are found for complex types
*
* @param {string} templateDir Directory where metadata templates are stored
Expand Down
8 changes: 4 additions & 4 deletions lib/metadataTypes/Query.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class Query extends MetadataType {
return metadata;
}
/**
* helper for buildDefinitionForNested
* helper for {@link buildDefinitionForNested}
* searches extracted SQL file for template variables and applies the market values
*
* @param {string} code code from extracted code
Expand All @@ -159,7 +159,7 @@ class Query extends MetadataType {
return Mustache.render(code, templateVariables);
}
/**
* helper for buildDefinition
* helper for {@link MetadataType.buildDefinition}
* handles extracted code if any are found for complex types
*
* @param {string} templateDir Directory where metadata templates are stored
Expand All @@ -186,7 +186,7 @@ class Query extends MetadataType {
);
}
/**
* helper for buildTemplate
* helper for {@link MetadataType.buildTemplate}
* handles extracted code if any are found for complex types
*
* @example queries are saved as 1 json and 1 sql file. both files need to be run through templating
Expand Down Expand Up @@ -214,7 +214,7 @@ class Query extends MetadataType {
);
}
/**
* helper for buildTemplateForNested / buildDefinitionForNested
* helper for {@link buildTemplateForNested} / {@link buildDefinitionForNested}
* handles extracted code if any are found for complex types
*
* @private
Expand Down
8 changes: 4 additions & 4 deletions lib/metadataTypes/Script.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class Script extends MetadataType {
}

/**
* helper for this.preDeployTasks() that loads extracted code content back into JSON
* helper for {@link preDeployTasks} that loads extracted code content back into JSON
*
* @param {TYPE.ScriptItem} metadata a single asset definition
* @param {string} deployDir directory of deploy files
Expand Down Expand Up @@ -137,7 +137,7 @@ class Script extends MetadataType {
return metadata;
}
/**
* helper for buildDefinition
* helper for {@link MetadataType.buildDefinition}
* handles extracted code if any are found for complex types
*
* @param {string} templateDir Directory where metadata templates are stored
Expand All @@ -164,7 +164,7 @@ class Script extends MetadataType {
);
}
/**
* helper for buildTemplate
* helper for {@link MetadataType.buildTemplate}
* handles extracted code if any are found for complex types
*
* @example scripts are saved as 1 json and 1 ssjs file. both files need to be run through templating
Expand Down Expand Up @@ -193,7 +193,7 @@ class Script extends MetadataType {
}

/**
* helper for buildTemplateForNested / buildDefinitionForNested
* helper for {@link buildTemplateForNested} / {@link buildDefinitionForNested}
* handles extracted code if any are found for complex types
*
* @param {string} templateDir Directory where metadata templates are stored
Expand Down
6 changes: 6 additions & 0 deletions lib/metadataTypes/definitions/Folder.definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,5 +175,11 @@ module.exports = {
retrieving: false,
template: false,
},
_generated: {
isCreateable: false,
isUpdateable: false,
retrieving: false,
template: false,
},
},
};
Loading

0 comments on commit 335ec9d

Please sign in to comment.