Skip to content

Commit

Permalink
Merge pull request #947 from Accenture/develop
Browse files Browse the repository at this point in the history
5.0.2
  • Loading branch information
JoernBerkefeld authored May 30, 2023
2 parents 9a13cbc + 2791d80 commit 537707f
Show file tree
Hide file tree
Showing 68 changed files with 1,023 additions and 488 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
}
}
],
"jsdoc/tag-lines": ["warn", "any", { "startLines": 1 }],
"spaced-comment": ["warn", "always", { "block": { "exceptions": ["*"], "balanced": true } }]
},
"overrides": [
Expand Down
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:
- 5.0.2
- 5.0.1
- 5.0.0
- 4.3.4
Expand Down
2 changes: 1 addition & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
. "$(dirname "$0")/_/husky.sh"
INPUT_FILE=$1
START_LINE=`head -n1 $INPUT_FILE`
PATTERN="^(#[[:digit:]]|Merge)"
PATTERN="^(#[[:digit:]]|Merge|Revert)"

if ! [[ "$START_LINE" =~ $PATTERN ]] ; then
echo "Bad commit message, see example: \"#431 commit message\", you provided: \"$START_LINE\""
Expand Down
37 changes: 34 additions & 3 deletions .husky/post-checkout
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

# ### git commit message template ###
git config commit.template .git/templatemessage
TICKETID=`git rev-parse --abbrev-ref HEAD | LC_ALL=en_US.utf8 grep -oP '((feature|bug|bugfix|fix|hotfix|task|chore)\/)\K\d{1,7}'`
echo "[POST_CHECKOUT] Setting template commit to $TICKETID"
echo "#$TICKETID: " > ".git/templatemessage"
TICKETID=`git rev-parse --abbrev-ref HEAD | LC_ALL=en_US.utf8 grep -oP '^((feature|bug|bugfix|fix|hotfix|task|chore)\/)?\K\d{1,7}' || true`
if [ -z "$TICKETID" ]
then
TICKETID="0"
fi
TEMPLATE="#$TICKETID: "
echo "[POST_CHECKOUT] Setting template commit to '$TEMPLATE'"
echo $TEMPLATE > ".git/templatemessage"


# ### run npm install ###
echo "[POST-CHECKOUT] 📦 Checking for changes to dependencies"
# define how to split strings into array elements
IFS=$'\n'
# $1 is the new HEAD pointer
NEWHEAD=$1
# $2 is the previous HEAD pointer
OLDHEAD=$2
# extract all paths to package-lock.json files
PACKAGE_LOCK_REGEX="(^package-lock\.json)"
PACKAGES=$(git diff --name-only $NEWHEAD $OLDHEAD | grep -E $PACKAGE_LOCK_REGEX || true)

if [[ ${PACKAGES[@]} ]]; then
for package in $PACKAGES; do
echo "📦 $package was changed."
done
echo "📦 Running npm install to update your dependencies..."
npm install
else
echo "📦 All packages up-to-date. No need to run npm install."
fi
21 changes: 21 additions & 0 deletions .husky/post-merge
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh
# ### run npm install ###
. "$(dirname "$0")/_/husky.sh"


echo "[POST-MERGE] 📦 Checking for changes to dependencies"

IFS=$'\n'
# extract all paths to package-lock.json files
PACKAGE_LOCK_REGEX="(^package-lock\.json)"
PACKAGES=$(git diff --name-only HEAD^1 HEAD | grep -E $PACKAGE_LOCK_REGEX || true)

if [[ ${PACKAGES[@]} ]]; then
for package in $PACKAGES; do
echo "📦 $package was changed."
done
echo "📦 Running npm install to update your dependencies..."
npm install
else
echo "📦 All packages up-to-date. No need to run npm install."
fi
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run docs
git update-index --add docs/dist/documentation.md
npx --no lint-staged
75 changes: 60 additions & 15 deletions docs/dist/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,7 @@ Automation MetadataType
* [.update(metadata, metadataBefore)](#Automation.update) ⇒ <code>Promise</code>
* [.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>
* [.postDeployTasks(metadataMap, originalMetadataMap)](#Automation.postDeployTasks) ⇒ <code>Promise.&lt;void&gt;</code>
* [.setFolderPath(metadata)](#Automation.setFolderPath)
* [.setFolderId(metadata)](#Automation.setFolderId)
* [.parseMetadata(metadata)](#Automation.parseMetadata) ⇒ <code>TYPE.AutomationItem</code> \| <code>void</code>
Expand Down Expand Up @@ -1345,16 +1345,16 @@ Whitelisted Activites are deployed but require configuration

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

### Automation.postDeployTasks(metadata, originalMetadata) ⇒ <code>Promise.&lt;void&gt;</code>
### Automation.postDeployTasks(metadataMap, originalMetadataMap) ⇒ <code>Promise.&lt;void&gt;</code>
Gets executed after deployment of metadata type

**Kind**: static method of [<code>Automation</code>](#Automation)
**Returns**: <code>Promise.&lt;void&gt;</code> - -

| Param | Type | Description |
| --- | --- | --- |
| metadata | <code>TYPE.AutomationMap</code> | metadata mapped by their keyField |
| originalMetadata | <code>TYPE.AutomationMap</code> | metadata to be updated (contains additioanl fields) |
| metadataMap | <code>TYPE.AutomationMap</code> | metadata mapped by their keyField |
| originalMetadataMap | <code>TYPE.AutomationMap</code> | metadata to be updated (contains additioanl fields) |

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

Expand Down Expand Up @@ -3167,6 +3167,7 @@ Provides default functionality that can be overwritten by child metadata type cl
* [.getSOAPErrorMsg(ex)](#MetadataType.getSOAPErrorMsg) ⇒ <code>string</code>
* [.retrieveSOAP(retrieveDir, [requestParams], [singleRetrieve], [additionalFields])](#MetadataType.retrieveSOAP) ⇒ <code>Promise.&lt;TYPE.MetadataTypeMapObj&gt;</code>
* [.retrieveREST(retrieveDir, uri, [templateVariables], [singleRetrieve])](#MetadataType.retrieveREST) ⇒ <code>Promise.&lt;{metadata: (TYPE.MetadataTypeMap\|TYPE.MetadataTypeItem), type: string}&gt;</code>
* [.runDocumentOnRetrieve([singleRetrieve], metadataMap)](#MetadataType.runDocumentOnRetrieve) ⇒ <code>Promise.&lt;void&gt;</code>
* [.parseResponseBody(body, [singleRetrieve])](#MetadataType.parseResponseBody) ⇒ <code>TYPE.MetadataTypeMap</code>
* [.deleteFieldByDefinition(metadataEntry, fieldPath, definitionProperty, origin)](#MetadataType.deleteFieldByDefinition) ⇒ <code>void</code>
* [.removeNotCreateableFields(metadataEntry)](#MetadataType.removeNotCreateableFields) ⇒ <code>void</code>
Expand Down Expand Up @@ -3632,6 +3633,19 @@ Retrieves Metadata for Rest Types
| [templateVariables] | <code>TYPE.TemplateMap</code> | variables to be replaced in the metadata |
| [singleRetrieve] | <code>string</code> \| <code>number</code> | key of single item to filter by |

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

### MetadataType.runDocumentOnRetrieve([singleRetrieve], metadataMap) ⇒ <code>Promise.&lt;void&gt;</code>
helper for [retrieveREST](retrieveREST) and [retrieveSOAP](retrieveSOAP)

**Kind**: static method of [<code>MetadataType</code>](#MetadataType)
**Returns**: <code>Promise.&lt;void&gt;</code> - -

| Param | Type | Description |
| --- | --- | --- |
| [singleRetrieve] | <code>string</code> \| <code>number</code> | key of single item to filter by |
| metadataMap | <code>TYPE.MetadataTypeMap</code> | saved metadata |

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

### MetadataType.parseResponseBody(body, [singleRetrieve]) ⇒ <code>TYPE.MetadataTypeMap</code>
Expand Down Expand Up @@ -4006,11 +4020,13 @@ MobileKeyword MetadataType

* [MobileKeyword](#MobileKeyword)[<code>MetadataType</code>](#MetadataType)
* [.retrieve(retrieveDir, [_], [__], [key])](#MobileKeyword.retrieve) ⇒ <code>Promise.&lt;TYPE.MetadataTypeMapObj&gt;</code> \| <code>void</code>
* [.parseResponseBody(body, [singleRetrieve])](#MobileKeyword.parseResponseBody) ⇒ <code>TYPE.MetadataTypeMap</code>
* [.createOrUpdate(metadataMap, metadataKey, hasError, metadataToUpdate, metadataToCreate)](#MobileKeyword.createOrUpdate) ⇒ <code>&#x27;create&#x27;</code> \| <code>&#x27;update&#x27;</code> \| <code>&#x27;skip&#x27;</code>
* [.retrieveForCache(_, __, [key])](#MobileKeyword.retrieveForCache) ⇒ <code>Promise.&lt;TYPE.MetadataTypeMapObj&gt;</code>
* [.retrieveAsTemplate(templateDir, name, templateVariables)](#MobileKeyword.retrieveAsTemplate) ⇒ <code>Promise.&lt;TYPE.MetadataTypeItemObj&gt;</code>
* [.create(MobileKeyword)](#MobileKeyword.create) ⇒ <code>Promise</code>
* [.retrieveAsTemplate(templateDir, key, templateVariables)](#MobileKeyword.retrieveAsTemplate) ⇒ <code>Promise.&lt;TYPE.MetadataTypeItemObj&gt;</code>
* [.create(metadata)](#MobileKeyword.create) ⇒ <code>Promise</code>
* [.update(metadata)](#MobileKeyword.update) ⇒ <code>Promise</code>
* [.postRetrieveTasks(metadata)](#MobileKeyword.postRetrieveTasks) ⇒ <code>TYPE.CodeExtractItem</code> \| <code>TYPE.MetadataTypeItem</code>
* [.postRetrieveTasks(metadata)](#MobileKeyword.postRetrieveTasks) ⇒ <code>TYPE.CodeExtractItem</code> \| <code>TYPE.MetadataTypeItem</code> \| <code>void</code>
* [.prepExtractedCode(metadataScript)](#MobileKeyword.prepExtractedCode) ⇒ <code>Object</code>
* [.buildDefinitionForNested(templateDir, targetDir, metadata, templateVariables, templateName)](#MobileKeyword.buildDefinitionForNested) ⇒ <code>Promise.&lt;Array.&lt;Array.&lt;string&gt;&gt;&gt;</code>
* [.buildTemplateForNested(templateDir, targetDir, metadata, templateVariables, templateName)](#MobileKeyword.buildTemplateForNested) ⇒ <code>Promise.&lt;Array.&lt;Array.&lt;string&gt;&gt;&gt;</code>
Expand Down Expand Up @@ -4039,6 +4055,35 @@ Endpoint /legacy/v1/beta/mobile/keyword/ return all Mobile Keywords with all det
| [__] | <code>void</code> | unused parameter |
| [key] | <code>string</code> | customer key of single item to retrieve |

<a name="MobileKeyword.parseResponseBody"></a>

### MobileKeyword.parseResponseBody(body, [singleRetrieve]) ⇒ <code>TYPE.MetadataTypeMap</code>
Builds map of metadata entries mapped to their keyfields

**Kind**: static method of [<code>MobileKeyword</code>](#MobileKeyword)
**Returns**: <code>TYPE.MetadataTypeMap</code> - keyField => metadata map

| Param | Type | Description |
| --- | --- | --- |
| body | <code>object</code> | json of response body |
| [singleRetrieve] | <code>string</code> \| <code>number</code> | key of single item to filter by |

<a name="MobileKeyword.createOrUpdate"></a>

### MobileKeyword.createOrUpdate(metadataMap, metadataKey, hasError, metadataToUpdate, metadataToCreate) ⇒ <code>&#x27;create&#x27;</code> \| <code>&#x27;update&#x27;</code> \| <code>&#x27;skip&#x27;</code>
helper for [upsert](#MetadataType.upsert)

**Kind**: static method of [<code>MobileKeyword</code>](#MobileKeyword)
**Returns**: <code>&#x27;create&#x27;</code> \| <code>&#x27;update&#x27;</code> \| <code>&#x27;skip&#x27;</code> - action to take

| Param | Type | Description |
| --- | --- | --- |
| metadataMap | <code>TYPE.MetadataTypeMap</code> | list of metadata |
| metadataKey | <code>string</code> | key of item we are looking at |
| hasError | <code>boolean</code> | error flag from previous code |
| metadataToUpdate | <code>Array.&lt;TYPE.MetadataTypeItemDiff&gt;</code> | list of items to update |
| metadataToCreate | <code>Array.&lt;TYPE.MetadataTypeItem&gt;</code> | list of items to create |

<a name="MobileKeyword.retrieveForCache"></a>

### MobileKeyword.retrieveForCache(_, __, [key]) ⇒ <code>Promise.&lt;TYPE.MetadataTypeMapObj&gt;</code>
Expand All @@ -4055,29 +4100,29 @@ Retrieves event definition metadata for caching

<a name="MobileKeyword.retrieveAsTemplate"></a>

### MobileKeyword.retrieveAsTemplate(templateDir, name, templateVariables) ⇒ <code>Promise.&lt;TYPE.MetadataTypeItemObj&gt;</code>
Retrieve a specific keyword
### MobileKeyword.retrieveAsTemplate(templateDir, key, templateVariables) ⇒ <code>Promise.&lt;TYPE.MetadataTypeItemObj&gt;</code>
retrieve an item and create a template from it

**Kind**: static method of [<code>MobileKeyword</code>](#MobileKeyword)
**Returns**: <code>Promise.&lt;TYPE.MetadataTypeItemObj&gt;</code> - Promise of metadata

| Param | Type | Description |
| --- | --- | --- |
| templateDir | <code>string</code> | Directory where retrieved metadata directory will be saved |
| name | <code>string</code> | name of the metadata file |
| key | <code>string</code> | name of the metadata file |
| templateVariables | <code>TYPE.TemplateMap</code> | variables to be replaced in the metadata |

<a name="MobileKeyword.create"></a>

### MobileKeyword.create(MobileKeyword) ⇒ <code>Promise</code>
Creates a single Event Definition
### MobileKeyword.create(metadata) ⇒ <code>Promise</code>
Creates a single item

**Kind**: static method of [<code>MobileKeyword</code>](#MobileKeyword)
**Returns**: <code>Promise</code> - Promise

| Param | Type | Description |
| --- | --- | --- |
| MobileKeyword | <code>TYPE.MetadataTypeItem</code> | a single Event Definition |
| metadata | <code>TYPE.MetadataTypeItem</code> | a single item |

<a name="MobileKeyword.update"></a>

Expand All @@ -4093,11 +4138,11 @@ Updates a single item

<a name="MobileKeyword.postRetrieveTasks"></a>

### MobileKeyword.postRetrieveTasks(metadata) ⇒ <code>TYPE.CodeExtractItem</code> \| <code>TYPE.MetadataTypeItem</code>
### MobileKeyword.postRetrieveTasks(metadata) ⇒ <code>TYPE.CodeExtractItem</code> \| <code>TYPE.MetadataTypeItem</code> \| <code>void</code>
manages post retrieve steps

**Kind**: static method of [<code>MobileKeyword</code>](#MobileKeyword)
**Returns**: <code>TYPE.CodeExtractItem</code> \| <code>TYPE.MetadataTypeItem</code> - Array with one metadata object and one ssjs string
**Returns**: <code>TYPE.CodeExtractItem</code> \| <code>TYPE.MetadataTypeItem</code> \| <code>void</code> - Array with one metadata object and one ssjs string; or single metadata object; nothing if filtered

| Param | Type | Description |
| --- | --- | --- |
Expand Down
1 change: 0 additions & 1 deletion lib/Deployer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class Deployer {
/**
* Creates a Deployer, uses v2 auth if v2AuthOptions are passed.
*
*
* @param {TYPE.Mcdevrc} properties General configuration to be used in retrieve
* @param {TYPE.BuObject} buObject properties for auth
*/
Expand Down
16 changes: 8 additions & 8 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ yargs
},
})
.command({
command: 'buildDefinition <BU> <TYPE> <NAME> <MARKET>',
command: 'buildDefinition <BU> <TYPE> <FILENAME> <MARKET>',
aliases: ['bd'],
desc: 'builds metadata definition based on template',
builder: (yargs) => {
Expand All @@ -253,9 +253,9 @@ yargs
type: 'string',
describe: 'metadata type',
})
.positional('NAME', {
.positional('FILENAME', {
type: 'string',
describe: 'name of the metadata component',
describe: 'File name of the metadata template without the extension',
})
.positional('MARKET', {
type: 'string',
Expand All @@ -264,11 +264,11 @@ yargs
},
handler: (argv) => {
Mcdev.setOptions(argv);
Mcdev.buildDefinition(argv.BU, argv.TYPE, argv.NAME, argv.MARKET);
Mcdev.buildDefinition(argv.BU, argv.TYPE, argv.FILENAME, argv.MARKET);
},
})
.command({
command: 'buildDefinitionBulk <LISTNAME> <TYPE> <NAME>',
command: 'buildDefinitionBulk <LISTNAME> <TYPE> <FILENAME>',
aliases: ['bdb'],
desc: 'builds metadata definition based on template en bulk',
builder: (yargs) => {
Expand All @@ -281,14 +281,14 @@ yargs
type: 'string',
describe: 'metadata type',
})
.positional('NAME', {
.positional('FILENAME', {
type: 'string',
describe: 'name of the metadata component',
describe: 'File name of the metadata template without the extension',
});
},
handler: (argv) => {
Mcdev.setOptions(argv);
Mcdev.buildDefinitionBulk(argv.LISTNAME, argv.TYPE, argv.NAME);
Mcdev.buildDefinitionBulk(argv.LISTNAME, argv.TYPE, argv.FILENAME);
},
})
.command({
Expand Down
3 changes: 2 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,12 @@ class Mcdev {
cred = buObject.credential;
bu = buObject.businessUnit;
// clean up old folders after types were renamed
// TODO: Remove this with version 5.0.0
// TODO: Remove renamedTypes-logic 6 months after version 5 release
const renamedTypes = {
emailSend: 'emailSendDefinition',
event: 'eventDefinition',
fileLocation: 'ftpLocation',
journey: 'interaction',
triggeredSend: 'triggeredSendDefinition',
user: 'accountUser',
};
Expand Down
6 changes: 4 additions & 2 deletions lib/metadataTypes/Asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ class Asset extends MetadataType {
static async retrieve(retrieveDir, _, subTypeArr, key) {
const items = [];
subTypeArr ||= this._getSubTypes();
await File.initPrettier();
if (retrieveDir) {
await File.initPrettier();
}
// loop through subtypes and return results of each subType for caching (saving is handled per subtype)
for (const subType of subTypeArr) {
// each subtype contains multiple different specific types (images contains jpg and png for example)
Expand Down Expand Up @@ -235,7 +237,7 @@ class Asset extends MetadataType {
rightOperand: {
property: 'id',
simpleOperator: 'greaterThan',
value: items[items.length - 1].id,
value: items.at(-1).id,
},
};
lastPage = 0;
Expand Down
Loading

0 comments on commit 537707f

Please sign in to comment.