Configuration file

When you initialize a new repository, the CLI will grab your company information from Constructor and pull that information into the repository to give you a starting point.

The initial repository includes a configuration file (connectrc.js) that will list all connectors you currently have configured, as well as their environments and a few other pieces of information. The configuration file is meant to map which templates to use in which connections.

It is possible to have multiple connectors configured. You may opt to use different template files for each, or simplify your setup and use the same templates if possible.

Templates are explicitly linked

The configuration file exists to link templates to your connectors. If a template is not linked, then you will not be able to execute it, and it will not be deployed to our servers when you run npm run deploy.

Templates need to be explicitly linked to your connections, for each environment, so that they can influence your catalog integration.

Templates are optional

Every template defined under environments.templates.paths is optional. The CLI may generate a repository with all available templates, but you can opt out if you do not plan to use them.

📘

How do I opt out from a certain template?

Say that you do not plan to transform item groups. In this case, you would delete the item_group.jsonata template from your repository and remove any links from the connectrc.js configuration file so that it is not deployed.

You can also remove any other references, such as tests or fixtures.

Example configuration file

Here's an example of how the configuration file looks:

// @ts-check

const connections = {
  "My development connection": {
    "id": "dev_connection_id",
    "slug": "con_xxxxxxxxxxxxxxxx",
    "environment": "development"
  },
  "My qa connection": {
    "id": "qa_connection_id",
    "slug": "con_xxxxxxxxxxxxxxxx",
    "environment": "qa"
  },
  "My production connection": {
    "id": "prod_connection_id",
    "slug": "con_xxxxxxxxxxxxxxxx",
    "environment": "production"
  }
};

/**
 * Defines your CLI configuration.
 *
 * This object maps your Constructor indexes to your templates, effectively enabling you to have
 * multiple environments, multiple templates per environment and per index.
 *
 * @type {import("@constructor-io/constructorio-connect-cli/dist/types").Config}
 */
const config = {
  "template_repository_version": "1.0.0",
  "helpers": "src/templates/helpers.jsonata",
  "environments": [
    {
      "environment": "development",
      "templates": [
        {
          "connection_ids": [
            connections["My development connection"].id
          ],
          "paths": {
            "item": "src/templates/item/item.jsonata",
            "variation": "src/templates/variation/variation.jsonata",
            "item_group": "src/templates/item_group/item_group.jsonata",
            "grouping": "src/templates/grouping/grouping.jsonata",
            "mapping": "src/templates/mapping/mapping.jsonata"
          }
        }
      ]
    },
    {
      "environment": "qa",
      "templates": [
        {
          "connection_ids": [
            connections["My qa connection"].id
          ],
          "paths": {
            "item": "src/templates/item/item.jsonata",
            "variation": "src/templates/variation/variation.jsonata",
            "item_group": "src/templates/item_group/item_group.jsonata",
            "grouping": "src/templates/grouping/grouping.jsonata",
            "mapping": "src/templates/mapping/mapping.jsonata"
          }
        }
      ]
    },
    {
      "environment": "production",
      "templates": [
        {
          "connection_ids": [
            connections["My production connection"].id
          ],
          "paths": {
            "item": "src/templates/item/item.jsonata",
            "variation": "src/templates/variation/variation.jsonata",
            "item_group": "src/templates/item_group/item_group.jsonata",
            "grouping": "src/templates/grouping/grouping.jsonata",
            "mapping": "src/templates/mapping/mapping.jsonata"
          }
        }
      ]
    }
  ]
};

module.exports = config;

What’s Next