When you call sfdx force:force:push there is no param to specify which artifact you'd like to push.

In the ./sfdx-project.json file you have package directories and you can specify a default:

  "packageDirectories": [
      "path": "my-main-artifact",
      "default": true
      "path": "my-less-important-artifact",
      "default": false
  "namespace": "",
  "sfdcLoginUrl": "https://login.salesforce.com",
  "sourceApiVersion": "42.0"

So presumably it's picking my-main-artifact as the one to push?

If I have multiple artifacts in this repo though how do I easily switch between the one I want to push? It's like there is an "active" artifact - is this just controlled from that default flag?

  • Just bumping an old thread here to see if there is an update on this discovery? – VarunC Dec 12 '19 at 13:21

The short answer is no, you can't control which artifact to push with sfdx-project.json

The CLI uses the default package directory as the target directory when pulling changes in the scratch org to sync the local project. This default path is also used when creating second-generation packages.

Salesforce DX Developer Guide

That means all what specified in sfdx-project.json will be affected by force:status/push/pull. This setting only allow CLI to identify where to put newly created components on scratch org when doing force:pull, that do not belong to any artifact yet.

Let me share my expirience here

That is ok to use this approach if artifacts do not depend on each other, but in my case they do.

As a workaround or tmp solution, until we could specify additional params in force:push , which I hope would be available in the future, I use forceignore for that.

Here is piece of my sfdx-project.json.

{"path": "force-app/base", "default": true}, {"path": "force-app/ext_aff", "default": false}, {"path": "force-app/ext_amz", "default": false}

ext_aff & ext_amz can not be pushed together with base, because they have dependencies on sobjects. So, base and only it should go first and only then ext_aff & ext_amz could be pushed successfully.

Here is my flow for that:

  1. Create scratch
  2. Run force:status to have sourcePathInfos populated
  3. Update .forceignore and add force-app/ext_aff and force-app/ext_amz
  4. Run force:push, doing #3 pushes only base and ignores dependent extensions
  5. Update .forceignore and remove force-app/ext_aff and force-app/ext_amz
  6. Run force:push again and now extensions are pushed

After all of this I would be able to work scratch, update any exisitng metadata and successfully pull it. In case I need to create something new, I'll switch default flag to true on artifact where I want to put newly created component.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.