Skip to content

Customize Templates

Using the MMT CLI is the recommended method for updating templates so that you can hook it into your git version-control history and cut down on the manual work required to update several templates at one time through the Miva Admin.

MMT Workflow

Setup MMT

See the mvps-mmt repo for more information on getting started with MMT.

  1. Install MMT
    Terminal
    pip3 install miva-mmt
    
  2. Setup an SSH Key on your computer and add it to the stores you're working with
    Terminal
    cd ~/.ssh && ssh-keygen -t rsa -m pem -f mmt
    
    1. Copy the .pub file and paste it into the Miva Admin: Edit Profile > Manage SSH Authentication
      Terminal (mac)
      pbcopy > mmt.pub
      
  3. Add credentials, branches, & remotes through mmt
    Terminal
    mmt credential add --url='https://jsmith.mivamerchantdev.com/mm5/json.mvc' --ssh-username=support_jsmith --ssh-private-key='~/.ssh/mmt' jsmith
    mmt branch create develop --from production --store-code jsmith --credential-key jsmith
    mmt remote add jsmith/production --credential-key jsmith --branch-name production --store-code jsmith
    mmt remote add jsmith/develop --credential-key jsmith --branch-name develop --store-code jsmith
    

Download Templates

Change directories into the miva-templates/ directory and perform an $ mmt checkout

Terminal
cd miva-templates
mmt checkout jsmith/production

Modify Templates

  1. Update files in miva-templates/
  2. Push your changes up to your store's branch
    Terminal
    mmt push --notes="modified foo for x reason"
    

Working with Git Branches

As you switch between various git branches or $ git pull changes from other developers, you should use $ mmt checkout NAME_OF_REMOTE --reinitialize to tell mmt about the new branch's changes.

For example:

Terminal
git checkout feature/another-task
mmt checkout genesis/staging/jsmith --reinitialize
mmt push --notes="pushing latest changes from feature/another-task"

Sample ~/.mmt/config.json

Consider some of the following strategies & settings for setting up your MMT workflow with Genesis

{
    "version": 1,
    "settings": {
        "editor": ["code", "-w"],
        "diff": ["code", "-w", "--diff", "%old_file% %new_file%"]
    },
    "credentials": {
        "acme/live": {
            "url": "https://www.acme.com/mm5/json.mvc",
            "username": "support_jsmith",
            "filepath": "C:\\Users\\jsmith\\.ssh\\mmt"
        },
        "acme/staging": {
            "url": "https://dev.acme.com/mm5/json.mvc",
            "username": "support_jsmith",
            "filepath": "C:\\Users\\jsmith\\.ssh\\mmt"
        },
        "acme/dev": {
            "url": "https://jsmith.mivamerchantdev.com/mm5/json.mvc",
            "username": "support_jsmith",
            "filepath": "C:\\Users\\jsmith\\.ssh\\mmt"
        },
    },
    "remotes": {
        "acme/live/production": {
            "credential_key": "acme/live",
            "store_code": "ACME",
            "branch_name": "production"
        },
        "acme/live/jsmith": {
            "credential_key": "acme/live",
            "store_code": "ACME",
            "branch_name": "jsmith"
        },
        "acme/staging/production": {
            "credential_key": "acme/staging",
            "store_code": "ACME",
            "branch_name": "production"
        },
        "acme/staging/jsmith": {
            "credential_key": "acme/staging",
            "store_code": "ACME",
            "branch_name": "jsmith"
        },
        "acme/dev/production": {
            "credential_key": "jsmith",
            "store_code": "jsmith",
            "branch_name": "production"
        },
        "acme/dev/jsmith": {
            "credential_key": "jsmith",
            "store_code": "jsmith",
            "branch_name": "jsmith"
        }
    }
}