Giter Club home page Giter Club logo

commerce.plugin.conditionalconfigs's Introduction

Conditional Bootstrap plugin for Sitecore Commerce

This plugin was inspired by Guido van Tricht's ConditionalConfigs plugin (https://github.com/GuidovTricht/Sitecore.Commerce.Plugin.ConditionalConfigs)

This plugin adds conditional, rule based configuration for bootstrapping environment files.

How to use

When importing the json files from the environments folder, each file will be checked for a property named $conditions. You can put the $conditions property on any object node. Below is an example of the SQL Policy set that contains the connection configuration for the SharedEnvironments database in two different hosting environments: one is for development and one is for the test environment.

{
  "$type": "Sitecore.Commerce.Core.PolicySet, Sitecore.Commerce.Core",
  "Id": "Entity-PolicySet-SqlPolicySet",
  "Version": 1,
  "IsPersisted": false,
  "Name": "SqlPolicySet",
  "Policies": {
    "$type": "System.Collections.Generic.List`1[[Sitecore.Commerce.Core.Policy, Sitecore.Commerce.Core]], mscorlib",
    "$values": [
      {
        "$type": "Sitecore.Commerce.Plugin.SQL.EntityStoreSqlPolicy, Sitecore.Commerce.Plugin.SQL",
        "$conditions": {
          "HostingEnvironment": "dev"
        },
        "TrustedConnection": true,
        "UserName": "",
        "Password": "",
        "Server": ".",
        "Database": "SitecoreCommerce9_SharedEnvironments",
        "AdditionalParameters": "",
        "ConnectTimeout": 120000,
        "CommandTimeout": 180,
        "CleanEnvironmentCommandTimeout": 120000
      },
      {
        "$type": "Sitecore.Commerce.Plugin.SQL.EntityStoreSqlPolicy, Sitecore.Commerce.Plugin.SQL",
        "$conditions": {
          "HostingEnvironment": "tst"
        },
        "TrustedConnection": true,
        "UserName": "",
        "Password": "",
        "Server": "TestServer",
        "Database": "SitecoreCommerce9_SharedEnvironments",
        "AdditionalParameters": "",
        "ConnectTimeout": 120000,
        "CommandTimeout": 180,
        "CleanEnvironmentCommandTimeout": 120000
      }

    ]
  }
}

The $conditions property contains a dictionary where each key in the dictionary represents a setting in the AppSettings section of config.json and each value is the required value for the condition to be true. The value can be a regular expression.

When importing the policy json, the json will be checked for $conditions and for each node that has a condition, the plugin will check whether the conditions are true. If not, the node is removed from the json.

For example, if your config.json looks like this:

{
  "AppSettings": {
    "HostingEnvironment": "dev",
    "SiteTitle": "Sitecore Commerce Engine",
    "BootStrapFile": "Global",
    .
    .
    .

}

only the policies that have:

        "$conditions": {
          "HostingEnvironment": "dev"
        },

will be imported. Note that any policies that don't have a $conditions entry, will also be imported.

commerce.plugin.conditionalconfigs's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.