Skip to content

06.a ~ Admin Commands

Jörn Berkefeld edited this page Jun 7, 2024 · 4 revisions

init

Command: mcdev init

Alias: -

Creates the basic configuration file .mcdevrc.json and .mcdev-auth.json in your project directory. You may add more credentials by re-running the same command again, e.g. to add production and sandbox credentials next to each other.

In addition, it initializes an npm package for you, installs recommended npm dependencies and places our default IDE configuration files for ESLint, Prettier, Git and VSCode into your project directory.

The initialization ends with the creation of your Git repository and the first backup of your SFMC instance.

Example - initialize project / add additional credentials:

mcdev init

Example - update credentials:

mcdev init yourCredentialName

The interactive setup will ask you for an EID (Parent MID), Client ID and Client Secret of an installed package. It also asks for the Authentication Base Uri. Each installed package on a given SFMC instance shares the same tenant sub-domain and always shows you 3 domains (Auth, REST and SOAP).

Example URL: https://mcg123abcysykllg-0321cbs8bbt64.auth.marketingcloudapis.com

Note to CLI experts:

You can run this command without the interactive wizard asking questions using the --skipInteraction (or short--yes/--y) flag. In this case, you need to provide a few values in the command:

mcdev init --y.credentialName "yourCustomCredentialName" --y.client_id "yourClientIdHere" --y.client_secret "yourClientSecretHere" --y.auth_url "https://yourTenantSubdomainHere.auth.marketingcloudapis.com/" --y.gitRemoteUrl "https://my.git.server.com/myrepo.git" --y.account_id 00000000 --y.downloadBUs "true" --y.gitPush "true" --y.developmentBu "Name_of_my_DEV_BU"
CLI Argument Description
--y.credentialName Credential name of your Business Unit
--y.client_id Salesforce Marketing Cloud client ID
--y.client_secret Salesforce Marketing Cloud client secret
--y.auth_url Marketing cloud auth url
--y.gitRemoteUrl URL of your git remote repo
--y.account_id MID of the parent BU
--y.downloadBUs Download all the BUs: true or false
--y.gitPush Do the first git push: true or false
--y.developmentBu set the name of your development BU

join

Command: mcdev join

Alias: -

This command clones an existing Accenture SFMC DevTools project from a Git repository and sets up your local environment. It then creates the basic credentials file .mcdev-auth.json in your project directory and it installs recommended npm dependencies. One could use mcdev init instead, but this command nicely combines all necessary steps and ensures there are no issues during the git-clone process.

Example:

mcdev join

upgrade

Command: mcdev upgrade

Alias: mcdev up

This upgrades older Accenture SFMC DevTools projects to the newest standard: Outdated Accenture SFMC DevTools configuration files are upgraded and the right npm dependencies are installed. It also copies the right IDE configuration files into your project folder. See init for more details.

Example:

mcdev upgrade

reloadBUs

Command: mcdev reloadBUs [credential]

Alias: mcdev rb

Use this to synchronize your local list of available Business Units for a given credential. This is useful if you've added, deleted or renamed Business Units on your SFMC instance and want to make sure that your local setup reflects that - or if you accidentally changed your config file and want to restore it.

Example:

mcdev reloadBUs MyProject

badKeys

Command: mcdev badKeys [business unit]

Alias: -

Lists all metadata for which the External key is not in sync with the name to enable you to update them quickly.

Example:

mcdev badKeys MyProject/DEV

document

Command: mcdev document <business unit> <TYPE>

Alias: mcdev doc

Creates human-readable documentation for your metadata. This command is executed by default for supported types unless you changed your config manually (metaDataTypes.documentOnRetrieve). Therefore, running it manually is typically not required. You can choose to generate HTML (html) or Markdown (md) docs via options.documentType.

The default format is set to md as Markdown renders nicely in Git as well as in VSCode's Markdown preview and can be copied from there into Confluence and other applications without losing the formatting.

As standard roles are often not used by projects, we have the optional setting options.documentStandardRoles which is by default set to false

Currently supported types:

Name CLI Argument
Automation automation
Data Extension dataExtension
Role role
User accountUser

Example:

mcdev document myServer role

selectTypes

Command: mcdev selectTypes

Alias: mcdev st

Allows you to interactively select which metadata is retrieved when you run the retrieve command. Try out explainTypes first to understand what each type means.

Example:

mcdev selectTypes

Note: You may select non-standard types if you run mcdev selectTypes --debug. This may be needed in edge cases but is not recommended in most situations.

explainTypes

Command: mcdev explainTypes [--json]

Alias: mcdev et

A helper command for selectTypes. It prints out a table that defines what the various types are.

Types marked as not-default should be ignored. These are either under development or merely meant to support contributing to Accenture SFMC DevTools.

Example:

mcdev explainTypes

You can also add the parameter --json to instead get a more detailed output in json format.

mcdev explainTypes --json

which leads to the following (abbreviated here):

[
    {
        "name": "Triggered Send",
        "apiName": "triggeredSend",
        "retrieveByDefault": true,
        "supports": {
            "retrieve": true,
            "create": true,
            "update": true,
            "delete": true,
            "changeKey": true,
            "buildTemplate": true,
            "retrieveAsTemplate": false
        },
        "description": "DEPRECATED: Sends emails via API or DataExtension Event.",
    },
    {
        "name": "User",
        "apiName": "user",
        "retrieveByDefault": false,
        "supports": {
            "retrieve": true,
            "create": true,
            "update": true,
            "delete": false,
            "changeKey": true,
            "buildTemplate": true,
            "retrieveAsTemplate": false
        },
        "description": "Marketing Cloud users",
    }
]

resolveId

Command: mcdev resolveId [business unit] [metadata type] [metadata key]

Alias: mcdev rid

Tries to find the requested asset id and return the key and name as well as info on where it was shared from, if that is the case. This is particularly helpful if you have to deal with code that uses ContentBlockById a lot.

Example:

mcdev rid MyProject/DEV asset 4961
mcdev:: resolveId
 - Searching asset with id 4961 on BU MyProject/DEV
 - ID: 4961
 - Key: 20af5fbf-b4ac-4471-a7e6-2e3d5685c197
 - Name: footer_b2c_transactional
 - How to use:
   %%= ContentBlockByKey("20af5fbf-b4ac-4471-a7e6-2e3d5685c197") =%%
   %%= ContentBlockByName("Content Builder\Release 2 - BUILD\Content Blocks Library\05. Footer and Attachments\Referred content blocks\footer_b2c_transactional") =%%    
 - local link: ./retrieve/MyProject/DEV/asset/block/20af5fbf-b4ac-4471-a7e6-2e3d5685c197.asset-block-meta.html