/source-deploy-retrieve

JavaScript toolkit for working with Salesforce metadata.

Primary LanguageTypeScriptBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

Salesforce source-deploy-retrieve

CircleCI License npm (scoped) Commitizen friendly

Introduction

A JavaScript toolkit for working with Salesforce metadata. Built to support the SFDX deploy and retrieve experience in the Salesforce VS Code Extensions, CLI plugins, and other tools working with metadata.

Features

  • Resolve Salesforce metadata files into JavaScript objects
  • Parse and generate manifest files
  • Convert source files between SFDX File Formats
  • Generate metadata packages with the option to automatically create a zip file
  • Deploy and retrieve metadata with an org
  • An index to reference available metadata types.
  • Utilize promises with async/await syntax

Usage

Install the package:

npm install @salesforce/source-deploy-retrieve

Examples:

const { ComponentSet } = require('@salesforce/source-deploy-retrieve');

// Deploy a local set of Apex classes to an org
const deployResult = await ComponentSet
  .fromSource('/dev/MyProject/force-app/main/default/classes')
  .deploy({ usernameOrConnection: 'user@example.com' })
  .start();

// Retrieve metadata defined in a manifest file
const retrieveResult = await ComponentSet
  .fromManifest('/dev/my-project/manifest/package.xml')
  .retrieve({
    usernameOrConnection: 'user@example.com'
    output: '/dev/retrieve-result'
  })
  .start();

// Search for a particular CustomObject
const myObject = ComponentSet
  .fromSource([
    '/dev/my-project/force-app',
    '/dev/my-project/force-app-2'
  ])
  .find(component => {
    return component.fullName === 'MyObject__c' && component.type.name === 'CustomObject')
  });

See the examples folder for more code samples and guides.

Contributing

See CONTRIBUTING.md for details on how to contribute to the library.

See developing.md for details on building and testing the library locally.