Code Monkey home page Code Monkey logo

sfdx-falcon-template's Introduction

SFDX-Falcon Project Template

This template can be used as a starting point for any Salesforce DX project, but has been specialized for building managed packages. Each directory in this repository contains a README file describing its purpose, what type of files it should contain, and additional setup/configuration details (if needed).

Intro Video: Salesforce 201: Advanced Implementation for ISVs

License

This project is licensed under the MIT License - see the LICENSE file for details.

Getting Started

These instructions will get you a copy of the SFDX-Falcon template on your local machine and explain how to customize things for your project. They also explain how to distribute your project to developers once you're up and running.

If your environment meets all the prerequisites, setup and customization of this template should only take 5-10 minutes.

Prerequisites

Your Salesforce, GitHub, and Local environments should meet the following prerequisites. If you're missing any of these, make sure you address them in the order they appear in the lists, below.

Salesforce Environment Prerequisites

Prerequisite Reason More Info
Access to a Developer Hub Required for creating scratch orgs Enable the Dev Hub in Your Org
Create Salesforce DX Users Required for developers to access your Dev Hub Add Salesforce DX Users
Access to a Packaging Org Required for creating first-gen packages Overview of Salesforce Packages
Register a Namespace Prefix Required for creating managed packages Register a Namespace Prefix
Create a Managed Package Required for distribution on the AppExchange Create Salesforce Packages
Link your Namespace to your Dev Hub Required for creating namespaced scratch orgs Link a Namespace to a Dev Hub Org

GitHub Environment Prerequisites

Prerequisite Reason More Info
Create a new private GitHub repo Required for use as shared remote for your project Create a GitHub Repo
Invite collaborators (personal) Required for team development using personal account Invite Collaborators (personal)
Invite collaborators (organization) Required for team development using organization account Invite Collaborators (organization)

Local Environment Prerequisites

Prerequisite Reason More Info
OS, developer toolset, IDE and VCS Required by Salesforce CLI and for modern dev experience Salesforce DX System Requirements
Install the Salesforce CLI Required for using source-driven dev features of SFDX Install the Salesforce CLI

Important Note for Windows Users

For windows users there are now PowerShell scripts available in dev-tools-win.

How to Start a New Project From This Template

Step One: Clone the SFDX-Falcon Template repository (use HTTPS or SSH, not both)

# HTTPS Clone
git clone https://github.com/sfdx-isv/sfdx-falcon-template.git

# SSH Clone
git clone [email protected]:sfdx-isv/sfdx-falcon-template.git

Step Two: Create a new local directory for your project

mkdir my-new-sfdx-project

Step Three: Copy everything (including hidden files/directories) from sfdx-falcon-template to your project

cp -a  sfdx-falcon-template/.  my-new-sfdx-project

Step Four: Kill, then re-initialize Git in your project folder to start from a clean (empty) history

cd my-new-sfdx-project            # Change to your project directory
rm -rf .git                       # Remove .git, killing the sfdx-falcon-template history
git init                          # Re-initialize Git 
git add -A                        # Stage all files in your project directory
git commit -m "Initial commit"    # Perform the initial commit, starting your new history

Step Five: Add your GitHub repository as a remote of your new local repository (use HTTPS or SSH, not both)

# Add HTTPS remote
git remote add origin https://github.com/<USER_OR_ORGANIZATION_NAME>/<REPOSITORY_NAME>.git

# Add SSH remote
git remote add origin [email protected]:<USER_OR_ORGANIZATION_NAME>/<REPOSITORY_NAME>.git

Step Six: Make the initial push and add an upstream reference to your remote (via the -u flag)

git push -u origin master

You are now ready to connect the Salesforce CLI to your Dev Hub and Packaging Org.

Connect the Salesforce CLI to your Dev Hub and Packaging Org

If you have not previously connected the Salesforce CLI to your Dev Hub and Packaging Org, you will need to do so before continuing.

Connect the CLI to your Dev Hub

# force:auth:web:login
# -a --SETALIAS                   Set an alias for the authenticated org
# -d --SETDEFAULTDEVHUBUSERNAME   Set the authenticated org as the default
#                                 dev hub org for scratch org creation
sfdx force:auth:web:login -a DevHub -d

Connect the CLI to your Packaging Org

# force:auth:web:login
# -a --SETALIAS                   Set an alias for the authenticated org
sfdx force:auth:web:login -a my_ns_prefix-PACKAGING 

Connect the CLI to a Sandbox Org (Optional)

# force:auth:web:login
# -a --SETALIAS                   Set an alias for the authenticated org
# -r --INSTANCEURL                The login URL of the instance the org lives on
sfdx force:auth:web:login -a my_ns_prefix-SANDBOX -r https://test.salesforce.com

You are now ready to customize your Salesforce DX project and the SFDX-Falcon directories and scripts.

Final Customizations

In order to fully utilize the SFDX-Falcon Template, you should complete the following final customizations inside of your project/repository. Once these tasks are complete, you will be ready to download/convert metadata from your packaging org.

Customize SFDX-Falcon directory names

From the root of your project directory, rename the "my_ns_prefix" directory in sfdx-source so that it matches the namespace prefix of your managed package.

# Execute this from the root of your project directory
mv ./sfdx-source/my_ns_prefix ./sfdx-source/your_ns_prefix

Customize Salesforce DX project settings

There are two required edits (and one optional one) you need to make inside your sfdx-project.json file.

{
  "packageDirectories": [
    { "path": "sfdx-source/your_ns_prefix", "default": true },  <----- EDIT ONE: Your package's namespace
    { "path": "sfdx-source/unpackaged"},
    { "path": "sfdx-source/untracked"}
  ],
  "namespace": "your_ns_prefix", <------------------------------------ EDIT TWO: Your package's namespace
  "sfdcLoginUrl": "https://login.salesforce.com",
  "sourceApiVersion": "41.0" <---------------------------------------- OPTIONAL: Set this to the version you want
}

Customize Developer Tools

Follow the instructions in the dev-tools README for detailed information on how create and edit a local-config.sh so you can customize the behavior of the SFDX-Falcon dev-tools when deployed to your developer's machines.

Resources

List of resources TBA

Release History

Release history TBA.

Authors

Contributors

TODO: Need to add code of conduct and the process for submitting pull requests.

Acknowledgments

TODO

  • ????
  • ????
  • ????

Questions/Comments

Salesforce ISV Partners with questions/comments should join the SFDX-Falcon Chatter Group in the Partner Community. You can also reach out to the author, Vivek M. Chawla on Twitter - @VivekMChawla.

sfdx-falcon-template's People

Contributors

idanblich avatar jarrettkuljis avatar vivekmchawla avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sfdx-falcon-template's Issues

Explain meaning of each folder under Schema

I am wondering what type of date each of the folders under the Schema folder should contain. For example, Custom Metadata Types are stored in the customMetadata folder in DX, and it is confusing when I see customMetadata and customMetadataTypes folders in the Schema folder.

Another question is where should I keep data for applications (.app-meta.xml) of layouts?

packageDirectories is unreliable

I've noticed that splitting up apps into separate directories is unreliable - compilation fails with references not being found from across the package. Not sure what is a good way to replicate, but encountered few times before abolishing this approach completely.

The idea is to use default for common stuff such as helpers and objects, and AppA, AppB folders for any new features added to org. Is this approach not feasible?

How to use “sfdx force:source:pull” when folders other than “main/default” are used and components are added in the scratch org?

I've setup the folder structure for a new project following the patterns identified here. When I add e.g. a new SObject in the scratch org and use:

sfdx force:source:pull

the new components are put in a fixed folder "main/default" - there is no option to nominate the correct folder. So the folder structure is compromised.

(When components are already present locally in folders other than "main/default" the pull does place the changes correctly.)

Is there a work-around for this problem? If there isn't this multiple folder approach needs revising. So far I've wasted several hours trying to find a work around.

(Same question posted here https://salesforce.stackexchange.com/questions/206847/how-to-use-sfdx-forcesourcepull-when-folders-other-than-main-default-are-u.)

How to keep template users upgradable?

We took the Falcon template and adjusted it for ou purposes:

  1. Corrected errors
  2. Added CircleCI workflow steps
  3. Created Powershell version of the scripts
  4. Fixed bugs

What happens now when the repo is updated by Salesforce? The simple answer is we have to manually find and merge any change. Sure. But isn't there a better way to keep consumers of the template upgradable?

An idea could be to minimize the script parts to a minimum and provide a SFDX Falcon Plugin which only needs a ISV package specific configuration.

/dev-tools/setup-project-org-auth fails with Unexpected token ] in JSON at position 88

When trying to setup my Falcon project using no browser opens tpo Login to my DevHub org. Instead I get an error.

robert$ ./dev-tools/setup-project-org-auth 
\nLocal configuration variables set by ./dev-tools/lib/local-config.sh\n

PROJECT_ROOT -------------->  /Users/robert/dev/projects/travelexpenses
NAMESPACE_PREFIX ---------->  UP2GO_ITE
PACKAGE_NAME -------------->  Travel Expenses
DEFAULT_PACKAGE_DIR_NAME -->  /Users/robert/dev/projects/travelexpenses/sfdx-source/UP2GO_ITE
TARGET_ORG_ALIAS ----------> 
DEV_HUB_ALIAS ------------->  <%%-userAnswers.devHubAlias%>
SCRATCH_ORG_ALIAS --------->  UP2GO_ITE-SCRATCH
PACKAGING_ORG_ALIAS ------->  UP2GO_ITE-PACKAGING
SUBSCRIBER_ORG_ALIAS ------>  UP2GO_ITE-SUBSCRIBER
METADATA_PACKAGE_ID ------->  033F00000001hRi
PACKAGE_VERSION_ID -------->  04t0G000000T48F
SCRATCH_ORG_CONFIG -------->  /Users/robert/dev/projects/travelexpenses/config/project-scratch-def.json
GIT_REMOTE_URI ------------>  https://github.com/Up2Go/travelexpenses.git
ECHO_LOCAL_CONFIG_VARS ---->  true

Do you want to setup org authentication/aliases for this project?
(type YES to confirm, or hit ENTER to cancel) YES


Step 1 of 3: Setup authentication for this project's Dev Hub

Do you want set/replace the auth info for the <%%-userAnswers.devHubAlias%> alias?
(type YES to confirm, or hit ENTER to cancel) YES
\nWeb authentication in progress using default browser. Press CTRL+C to cancel.\n
ERROR:  Unexpected token ] in JSON at position 88.


WARNING: The web authentication request was canceled (or timed out).

Custom Metadata "records" not being synced

It seems like the **.md entry in .forceignore is interfering with processing the custom metadata records.
The file extension for the MDAPI files is .md, and the DX files are .md-meta.xml
I changed the entry to: *README.md to ignore the readme files and was able to pull/push/convert them.

Add option to set installationkey in tools/install-pkg-in-sandbox - Enhancement

Need to add option to set installationkey in tools/install-pkg-in-sandbox .
This can be part of the info in 'local-config.sh'
something like :
PACKAGE_INSTALLATIONKEY=""
And them in tools/install-pkg-in-sandbox
Use

if [ -n "$PACKAGE_INSTALLATIONKEY" ]; then 
  PACKAGE_INSTALLATIONKEY="--installationkey $PACKAGE_INSTALLATIONKEY"
fi
...
(cd $PROJECT_ROOT && exec sfdx force:package:install \
                                $PACKAGE_INSTALLATIONKEY \
                                --package $PACKAGE_VERSION_ID \
 ...

setup-project-org-auth fails with 'Unexpected argument https://test.salesforce.com'

Trying to set up my project , when running

 ./dev-tools/setup-project-org-auth 

result with :

Step 3 of 3: Setup authentication for this project's Subscriber Sandbox Org

Do you want set/replace the auth info for the  alias?
(type YES to confirm, or hit ENTER to cancel) YES
\nWeb authentication in progress using default browser. Press CTRL+C to cancel.\n
 ▸    Unexpected argument https://test.salesforce.com


WARNING: The web authentication request was canceled (or timed out).

Issue is here :

SUBSCRIBER_ORG_ALIAS="$NAMESPACE_PREFIX-SUBSCRIBER"

env parameter need to be called: SUBSCRIBER_SANDBOX_ALIAS in order to follow all reference in the code

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.