GithubHelp home page GithubHelp logo

crkelley / sfdx-browserforce-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from amtrack/sfdx-browserforce-plugin

0.0 0.0 0.0 3 MB

sfdx plugin for browser automation

License: MIT License

Shell 0.84% JavaScript 0.09% TypeScript 95.85% Batchfile 0.02% EJS 3.20%

sfdx-browserforce-plugin's Introduction

sfdx-browserforce-plugin

sfdx plugin for browser automation

Actions Status

Unlike the Scratch Org Definition Configuration which can only be used on the creation of a scratch org (sfdx force:org:create -f config/scratch-def.json), the Browserforce Configuration allows to "shape" any org, (e.g. scratch org, sandbox or production org) with similar preferences and unofficial preferences that are not (yet) available in the Scratch Org Definition Configuration or as Metadata (sfdx browserforce:apply -f config/setup-admin-login-as-any.json -u [email protected]).

Further benefits:

  • comfortable configuration using JSON Schema (similar to the Scratch Org Definition Configuration)
  • idempotency of the apply command only applies what's necessary and allows re-execution (concept similar to terraform)
  • browser automation powered by Puppeteer (Chromium)
  • implement your own custom preferences (a.k.a. plugins; to be improved)

Installation

There are several different methods to install sfdx-browserforce-plugin:

# as an sfdx plugin globally
sfdx plugins:install sfdx-browserforce-plugin

# or standalone globally
npm install --global sfdx-browserforce-plugin

# or standalone locally (as a dependency in your Node.js project)
npm install --save-dev sfdx-browserforce-plugin

Usage

Depending on your choice of installation, you can find the browserforce namespace:

# globally in the sfdx cli
sfdx browserforce

# globally in the sfdx-browserforce-plugin executable
sfdx-browserforce-plugin browserforce

# locally in the sfdx-browserforce-plugin executable (npx is awesome!)
npx sfdx-browserforce-plugin browserforce
$ sfdx-browserforce browserforce -h
browser automation

USAGE
  $ sfdx-browserforce-plugin browserforce:COMMAND

COMMANDS
  browserforce:apply  apply a plan from a definition file
  browserforce:plan   retrieve state and generate plan file

Both the browserforce:apply and browserforce:plan commands expect a config file and a target username or alias for the org.

Example

To enable Setup -> Security Controls -> Login Access Policies -> Administrators Can Log in as Any User, the config file (here: ./config/setup-admin-login-as-any.json) should look like this:

{
  "$schema": "https://raw.githubusercontent.com/amtrack/sfdx-browserforce-plugin/master/src/plugins/schema.json",
  "settings": {
    "security": {
      "loginAccessPolicies": {
        "administratorsCanLogInAsAnyUser": true
      }
    }
  }
}

Tip: If you use Visual Studio Code, you can leverage tab completion to build the config (powered by the JSON Schema).

Next apply the config:

$ sfdx browserforce:apply -f ./config/setup-admin-login-as-any.json --targetusername [email protected]
  logging in... done
  Applying definition file ./config/setup-admin-login-as-any.json to org [email protected]
  [Security] retrieving state... done
  [Security] changing 'loginAccessPolicies' to '{"administratorsCanLogInAsAnyUser":true}'... done
  logging out... done

Supported Settings

See the JSON Schema for all supported settings.

Here is a full blown example showing most of the supported settings in action:

{
  "$schema": "https://raw.githubusercontent.com/amtrack/sfdx-browserforce-plugin/master/src/plugins/schema.json",
  "settings": {
    "communities": { "enabled": true },
    "customerPortal": { "enabled": true },
    "deferSharingCalculation": {
      "suspend": true
    },
    "highVelocitySalesSettings": {
      "setUpAndEnable": true
    },
    "homePageLayouts": {
      "homePageLayoutAssignments": [
        {
          "profile": "Standard User",
          "layout": "Home Page Default"
        },
        {
          "profile": "System Administrator",
          "layout": "DE Default"
        }
      ]
    },
    "picklists": {
      "picklistValues": [
        {
          "metadataType": "StandardValueSet",
          "metadataFullName": "LeadSource",
          "value": "Partner",
          "newValue": "Partner Referral"
        },
        {
          "metadataType": "CustomField",
          "metadataFullName": "Vehicle__c.Features__c",
          "value": "CD",
          "newValue": "Media",
          "absent": true
        },
        {
          "metadataType": "CustomField",
          "metadataFullName": "Vehicle__c.Features__c",
          "value": "CD",
          "newValue": "AC",
          "active": false
        }
      ]
    },
    "recordTypes": { "deletions": [{ "fullName": "Vehicle__c.SUV" }] },
    "salesforceToSalesforce": { "enabled": true },
    "security": {
      "loginAccessPolicies": { "administratorsCanLogInAsAnyUser": true },
      "sharing": { "enableExternalSharingModel": true }
    }
  }
}

Environment Variables

  • BROWSER_DEBUG run in non-headless mode (default: false)
  • BROWSERFORCE_NAVIGATION_TIMEOUT_MS: adjustable for slow internet connections (default: 90000)
  • BROWSERFORCE_RETRY_MAX_RETRIES: number of retries on failures opening a page (default: 4)
  • BROWSERFORCE_RETRY_TIMEOUT_MS: initial time between retries in exponential mode (default: 4000)

Contributing

Please see CONTRIBUTING.md for getting started.

Sponsors

License

MIT © Matthias Rolke

sfdx-browserforce-plugin's People

Contributors

amtrack avatar renovate-bot avatar renovate[bot] avatar dependabot[bot] avatar gavinhughpalmer avatar aly76 avatar gulp-cm avatar jverelst 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.