Skip to content

Commit

Permalink
Merge pull request #500 from Accenture/develop
Browse files Browse the repository at this point in the history
4.1.4
  • Loading branch information
JoernBerkefeld authored Nov 1, 2022
2 parents 1829c9a + ead9d88 commit 56a0e9a
Show file tree
Hide file tree
Showing 27 changed files with 224 additions and 128 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.4
- 4.1.3
- 4.1.2
- 4.1.1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/code-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3

- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm ci
Expand All @@ -22,8 +22,8 @@ jobs:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ If you experience issues installing Accenture SFMC DevTools, please check out th
1. Install Accenture SFMC DevTools by running `npm install -g mcdev` (prefix with `sudo` on MacOS)
- If you get an error, please see the below troubleshooting section.

When completed run `mcdev --version` and it will show you which version you installed (e.g. `4.1.3`).
When completed run `mcdev --version` and it will show you which version you installed (e.g. `4.1.4`).

> **_Side note for proud nerds_:**
>
Expand Down Expand Up @@ -277,10 +277,10 @@ _Note: Regardless of which tag or branch you install_
**Install specific version (using a version tag on npm):**

```bash
npm install -g mcdev@4.1.3
npm install -g mcdev@4.1.4
```

**Warning**: When you used the above method to install Accenture SFMC DevTools for a specific version or tag, trying to [update Accenture SFMC DevTools](#updating-mcdev) might not download the most recently published official version but instead stay on the version or branch you previously selected (in the above examples: develop, 4.1.3)!
**Warning**: When you used the above method to install Accenture SFMC DevTools for a specific version or tag, trying to [update Accenture SFMC DevTools](#updating-mcdev) might not download the most recently published official version but instead stay on the version or branch you previously selected (in the above examples: develop, 4.1.4)!

> **Note**: The version is currently _not_ updated on the developer branch until a new release is published. Hence, you will not see a change if you run `mcdev --version`.
Expand Down Expand Up @@ -1493,7 +1493,7 @@ Assuming you cloned Accenture SFMC DevTools into `C:\repos\sfmc-devtools\` (or `
This should tell npm to create a symlink to your cloned local directoty, allowing you to see updates you make in your mcdev repo instantly.
To test your new **global** developer setup, run `mcdev --version` in CLI which should return the current version (e.g. `4.1.3`). Then, go into your mcdev repo and update the version with the suffix `-dev`, e.g. to `4.1.3-dev` and then run `mcdev --version` again to verify that your change propagates instantly.
To test your new **global** developer setup, run `mcdev --version` in CLI which should return the current version (e.g. `4.1.4`). Then, go into your mcdev repo and update the version with the suffix `-dev`, e.g. to `4.1.4-dev` and then run `mcdev --version` again to verify that your change propagates instantly.
> **Not recommended:** Alternatively, you can install it locally only by opening a terminal in your project directory and executing `npm install --save-dev "C:\repos\sfmc-devtools"`
> To run the local version you need to prepend "npx" before your commands, e.g. `npx mcdev --version`
Expand Down Expand Up @@ -1531,7 +1531,7 @@ The following explains how you _could_ install it locally for certain edge cases
4. Afterwards, install Accenture SFMC DevTools by running `npm install --save-dev mcdev`
- If you get an error, please see the below troubleshooting section.
When completed run `mcdev --version` and it will show you which version you installed (e.g. `4.1.3`).
When completed run `mcdev --version` and it will show you which version you installed (e.g. `4.1.4`).
### 9.3. NPM Scripts
Expand Down
61 changes: 61 additions & 0 deletions docs/dist/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,7 @@ FileTransfer MetadataType
* [.buildDefinitionForNested(templateDir, targetDir, metadata, templateVariables, templateName)](#Asset.buildDefinitionForNested) ⇒ <code>Promise.&lt;void&gt;</code>
* [.buildTemplateForNested(templateDir, targetDir, metadata, templateVariables, templateName)](#Asset.buildTemplateForNested) ⇒ <code>Promise.&lt;void&gt;</code>
* [._buildForNested(templateDir, targetDir, metadata, templateVariables, templateName, mode)](#Asset._buildForNested) ⇒ <code>Promise.&lt;void&gt;</code>
* [.setFolderPath(metadata)](#Asset.setFolderPath)
* [.parseMetadata(metadata)](#Asset.parseMetadata) ⇒ <code>TYPE.CodeExtractItem</code>
* [._mergeCode(metadata, deployDir, subType, [templateName], [fileListOnly])](#Asset._mergeCode) ⇒ <code>Promise.&lt;Array.&lt;TYPE.CodeExtract&gt;&gt;</code>
* [._mergeCode_slots(prefix, metadataSlots, readDirArr, subtypeExtension, subDirArr, fileList, customerKey, [templateName], [fileListOnly])](#Asset._mergeCode_slots) ⇒ <code>Promise.&lt;void&gt;</code>
Expand Down Expand Up @@ -1072,6 +1073,17 @@ handles extracted code if any are found for complex types
| templateName | <code>string</code> | name of the template to be built |
| mode | <code>&#x27;definition&#x27;</code> \| <code>&#x27;template&#x27;</code> | defines what we use this helper for |

<a name="Asset.setFolderPath"></a>

### Asset.setFolderPath(metadata)
generic script that retrieves the folder path from cache and updates the given metadata with it after retrieve

**Kind**: static method of [<code>Asset</code>](#Asset)

| Param | Type | Description |
| --- | --- | --- |
| metadata | <code>TYPE.MetadataTypeItem</code> | a single script activity definition |

<a name="Asset.parseMetadata"></a>

### Asset.parseMetadata(metadata) ⇒ <code>TYPE.CodeExtractItem</code>
Expand Down Expand Up @@ -1254,6 +1266,7 @@ Automation MetadataType
* [.preDeployTasks(metadata)](#Automation.preDeployTasks) ⇒ <code>Promise.&lt;TYPE.AutomationItem&gt;</code>
* [.validateDeployMetadata(metadata)](#Automation.validateDeployMetadata) ⇒ <code>boolean</code>
* [.postDeployTasks(metadata, originalMetadata)](#Automation.postDeployTasks) ⇒ <code>Promise.&lt;void&gt;</code>
* [.setFolderPath(metadata)](#Automation.setFolderPath)
* [.parseMetadata(metadata)](#Automation.parseMetadata) ⇒ <code>TYPE.AutomationItem</code>
* [._buildSchedule(scheduleObject)](#Automation._buildSchedule) ⇒ <code>TYPE.AutomationScheduleSoap</code>
* [._calcTime(offsetServer, dateInput, [offsetInput])](#Automation._calcTime) ⇒ <code>string</code>
Expand Down Expand Up @@ -1393,6 +1406,17 @@ Gets executed after deployment of metadata type
| metadata | <code>TYPE.AutomationMap</code> | metadata mapped by their keyField |
| originalMetadata | <code>TYPE.AutomationMap</code> | metadata to be updated (contains additioanl fields) |

<a name="Automation.setFolderPath"></a>

### Automation.setFolderPath(metadata)
generic script that retrieves the folder path from cache and updates the given metadata with it after retrieve

**Kind**: static method of [<code>Automation</code>](#Automation)

| Param | Type | Description |
| --- | --- | --- |
| metadata | <code>TYPE.MetadataTypeItem</code> | a single script activity definition |

<a name="Automation.parseMetadata"></a>

### Automation.parseMetadata(metadata) ⇒ <code>TYPE.AutomationItem</code>
Expand Down Expand Up @@ -1511,6 +1535,7 @@ ContentArea MetadataType
* [ContentArea](#ContentArea)[<code>MetadataType</code>](#MetadataType)
* [.retrieve(retrieveDir, [_], [__], [___], [key])](#ContentArea.retrieve) ⇒ <code>Promise.&lt;TYPE.MetadataTypeMapObj&gt;</code>
* [.postRetrieveTasks(metadata)](#ContentArea.postRetrieveTasks) ⇒ <code>TYPE.MetadataTypeItem</code>
* [.setFolderPath(metadata)](#ContentArea.setFolderPath)
* [.parseMetadata(metadata)](#ContentArea.parseMetadata) ⇒ <code>TYPE.MetadataTypeItem</code>

<a name="ContentArea.retrieve"></a>
Expand Down Expand Up @@ -1541,6 +1566,17 @@ manages post retrieve steps
| --- | --- | --- |
| metadata | <code>TYPE.MetadataTypeItem</code> | a single item |

<a name="ContentArea.setFolderPath"></a>

### ContentArea.setFolderPath(metadata)
generic script that retrieves the folder path from cache and updates the given metadata with it after retrieve

**Kind**: static method of [<code>ContentArea</code>](#ContentArea)

| Param | Type | Description |
| --- | --- | --- |
| metadata | <code>TYPE.MetadataTypeItem</code> | a single script activity definition |

<a name="ContentArea.parseMetadata"></a>

### ContentArea.parseMetadata(metadata) ⇒ <code>TYPE.MetadataTypeItem</code>
Expand Down Expand Up @@ -1576,6 +1612,7 @@ DataExtension MetadataType
* [.postDeleteTasks(buObject, customerKey)](#DataExtension.postDeleteTasks) ⇒ <code>void</code>
* [.retrieveForCache(buObject)](#DataExtension.retrieveForCache) ⇒ <code>Promise.&lt;{metadata: TYPE.DataExtensionMap, type: string}&gt;</code>
* [.retrieveAsTemplate(templateDir, name, templateVariables)](#DataExtension.retrieveAsTemplate) ⇒ <code>Promise.&lt;{metadata: TYPE.DataExtensionMap, type: string}&gt;</code>
* [.setFolderPath(metadata)](#DataExtension.setFolderPath)
* [.getFilesToCommit(keyArr)](#DataExtension.getFilesToCommit) ⇒ <code>Array.&lt;string&gt;</code>

<a name="DataExtension.upsert"></a>
Expand Down Expand Up @@ -1758,6 +1795,18 @@ Retrieves dataExtension metadata in template format.
| name | <code>string</code> | name of the metadata item |
| templateVariables | <code>TYPE.TemplateMap</code> | variables to be replaced in the metadata |

<a name="DataExtension.setFolderPath"></a>

### DataExtension.setFolderPath(metadata)
dataExtension logic that retrieves the folder path from cache and updates the given metadata with it after retrieve
it also sets the content type which is basically the subtype

**Kind**: static method of [<code>DataExtension</code>](#DataExtension)

| Param | Type | Description |
| --- | --- | --- |
| metadata | <code>TYPE.MetadataTypeItem</code> | a single script activity definition |

<a name="DataExtension.getFilesToCommit"></a>

### DataExtension.getFilesToCommit(keyArr) ⇒ <code>Array.&lt;string&gt;</code>
Expand Down Expand Up @@ -2946,6 +2995,7 @@ Provides default functionality that can be overwritten by child metadata type cl
* [.deploy(metadata, deployDir, retrieveDir, buObject)](#MetadataType.deploy) ⇒ <code>Promise.&lt;TYPE.MetadataTypeMap&gt;</code>
* [.postDeployTasks(metadata, originalMetadata)](#MetadataType.postDeployTasks) ⇒ <code>void</code>
* [.postRetrieveTasks(metadata, targetDir, [isTemplating])](#MetadataType.postRetrieveTasks) ⇒ <code>TYPE.MetadataTypeItem</code>
* [.setFolderPath(metadata)](#MetadataType.setFolderPath)
* [.retrieve(retrieveDir, [additionalFields], buObject, [subType], [key])](#MetadataType.retrieve) ⇒ <code>Promise.&lt;TYPE.MetadataTypeMapObj&gt;</code>
* [.retrieveChangelog([buObject], [additionalFields], [subType])](#MetadataType.retrieveChangelog) ⇒ <code>Promise.&lt;TYPE.MetadataTypeMapObj&gt;</code>
* [.retrieveForCache(buObject, [subType])](#MetadataType.retrieveForCache) ⇒ <code>Promise.&lt;TYPE.MetadataTypeMapObj&gt;</code>
Expand Down Expand Up @@ -3069,6 +3119,17 @@ Gets executed after retreive of metadata type
| targetDir | <code>string</code> | folder where retrieves should be saved |
| [isTemplating] | <code>boolean</code> | signals that we are retrieving templates |

<a name="MetadataType.setFolderPath"></a>

### MetadataType.setFolderPath(metadata)
generic script that retrieves the folder path from cache and updates the given metadata with it after retrieve

**Kind**: static method of [<code>MetadataType</code>](#MetadataType)

| Param | Type | Description |
| --- | --- | --- |
| metadata | <code>TYPE.MetadataTypeItem</code> | a single script activity definition |

<a name="MetadataType.retrieve"></a>

### MetadataType.retrieve(retrieveDir, [additionalFields], buObject, [subType], [key]) ⇒ <code>Promise.&lt;TYPE.MetadataTypeMapObj&gt;</code>
Expand Down
10 changes: 8 additions & 2 deletions lib/Retriever.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ class Retriever {
try {
let result;
if (!metadataTypes.includes(type) && !metadataTypes.includes(metadataType)) {
if (changelogOnly) {
// no extra caching needed for list view
if (changelogOnly && type !== 'folder') {
// no extra caching needed for list view except for folders
continue;
}
Util.logger.info(`Caching dependent Metadata: ${metadataType}`);
Expand Down Expand Up @@ -115,6 +115,12 @@ class Retriever {
)
)
));
if (changelogOnly) {
// add folder to changelog
for (const key of Object.keys(result.metadata)) {
MetadataTypeInfo[type].setFolderPath(result.metadata[key]);
}
}
}
if (result) {
if (Array.isArray(result)) {
Expand Down
26 changes: 17 additions & 9 deletions lib/metadataTypes/Asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -755,15 +755,12 @@ class Asset extends MetadataType {
}
}
}

/**
* parses retrieved Metadata before saving
* generic script that retrieves the folder path from cache and updates the given metadata with it after retrieve
*
* @param {TYPE.AssetItem} metadata a single asset definition
* @returns {TYPE.CodeExtractItem} parsed metadata definition
* @param {TYPE.MetadataTypeItem} metadata a single script activity definition
*/
static parseMetadata(metadata) {
// folder
static setFolderPath(metadata) {
try {
metadata.r__folder_Path = cache.searchForField(
'folder',
Expand All @@ -773,12 +770,23 @@ class Asset extends MetadataType {
);
delete metadata.category;
} catch (ex) {
// ! if we don't catch this error here we end up saving the actual asset but not its corresponding JSON
Util.logger.debug(ex.message);
Util.logger.warn(
` - Could not find folder with ID ${metadata.category.id} for '${metadata.name}' (${metadata.customerKey})`
` - ${this.definition.type} '${metadata[this.definition.nameField]}' (${
metadata[this.definition.keyField]
}): Could not find folder (${ex.message})`
);
}
}

/**
* parses retrieved Metadata before saving
*
* @param {TYPE.AssetItem} metadata a single asset definition
* @returns {TYPE.CodeExtractItem} parsed metadata definition
*/
static parseMetadata(metadata) {
// folder
this.setFolderPath(metadata);
// extract HTML for selected subtypes and convert payload for easier processing in MetadataType.saveResults()
metadata = this._extractCode(metadata);
return metadata;
Expand Down
35 changes: 23 additions & 12 deletions lib/metadataTypes/Automation.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class Automation extends MetadataType {
'ProgramID',
'Name',
'CustomerKey',
'CategoryID',
'LastSaveDate',
'LastSavedBy',
'CreatedBy',
Expand Down Expand Up @@ -457,23 +458,23 @@ class Automation extends MetadataType {
}
}
}

/**
* parses retrieved Metadata before saving
* generic script that retrieves the folder path from cache and updates the given metadata with it after retrieve
*
* @param {TYPE.AutomationItem} metadata a single automation definition
* @returns {TYPE.AutomationItem} parsed item
* @param {TYPE.MetadataTypeItem} metadata a single script activity definition
*/
static parseMetadata(metadata) {
// automations are often skipped due to lack of support.
static setFolderPath(metadata) {
const folderIdField = metadata[this.definition.folderIdField]
? this.definition.folderIdField
: 'CategoryID';
try {
metadata.r__folder_Path = cache.searchForField(
'folder',
metadata.categoryId,
metadata[folderIdField],
'ID',
'Path'
);
delete metadata.categoryId;
delete metadata[folderIdField];
if (metadata.r__folder_Path !== 'my automations') {
Util.logger.verbose(
`- automation '${
Expand All @@ -484,13 +485,23 @@ class Automation extends MetadataType {
);
}
} catch (ex) {
// * don't exit on missing folder for automation
Util.logger.warn(
` - ${this.definition.typeName} '${metadata[this.definition.nameField]}': ${
ex.message
}`
` - ${this.definition.type} '${metadata[this.definition.nameField]}' (${
metadata[this.definition.keyField]
}): Could not find folder (${ex.message})`
);
}
}

/**
* parses retrieved Metadata before saving
*
* @param {TYPE.AutomationItem} metadata a single automation definition
* @returns {TYPE.AutomationItem} parsed item
*/
static parseMetadata(metadata) {
this.setFolderPath(metadata);
// automations are often skipped due to lack of support.
try {
if (metadata.type === 'scheduled' && metadata.schedule?.startDate) {
// Starting Source == 'Schedule'
Expand Down
27 changes: 20 additions & 7 deletions lib/metadataTypes/ContentArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,40 @@ class ContentArea extends MetadataType {
return this.parseMetadata(metadata);
}
/**
* parses retrieved Metadata before saving
* generic script that retrieves the folder path from cache and updates the given metadata with it after retrieve
*
* @param {TYPE.MetadataTypeItem} metadata a single item
* @returns {TYPE.MetadataTypeItem} parsed item
* @param {TYPE.MetadataTypeItem} metadata a single script activity definition
*/
static parseMetadata(metadata) {
// folder
static setFolderPath(metadata) {
try {
metadata.r__folder_Path = cache.searchForField(
'folder',
metadata.CategoryID,
metadata[this.definition.folderIdField],
'ID',
'Path'
);
delete metadata[this.definition.folderIdField];
} catch (ex) {
Util.logger.debug(`Classic Content Area '${metadata.CustomerKey}': ${ex.message}`);
Util.logger.debug(
` - ${this.definition.type} '${metadata[this.definition.nameField]}' (${
metadata[this.definition.keyField]
}): Could not find folder (${ex.message})`
);
// classic content blocks that reside in the main folder are
// saved with CategoryID=0, instead of to the actual ID of
// their parent root folder.
metadata.r__folder_Path = 'my contents';
}
}
/**
* parses retrieved Metadata before saving
*
* @param {TYPE.MetadataTypeItem} metadata a single item
* @returns {TYPE.MetadataTypeItem} parsed item
*/
static parseMetadata(metadata) {
// folder
this.setFolderPath(metadata);

// extract code
const codeArr = [
Expand Down
Loading

0 comments on commit 56a0e9a

Please sign in to comment.