5

I've been developing my application using a Salesforce DX trial org (and accompanying CLI). My sfdc-project.json file is setup to use two paths for the source code as follows:

{ ...
  "packageDirectories": [
    {
      "path": "force-app",
      "default": true
    },
    {
      "path": "http-sdk"
    }
  ],
...
}

This has worked well for me to split my code base up between my app code and a set of HTTP API SDK classes I use. However, now that I'm trying to convert the project to an MDAPI format for packaging and distribution in the AppExchange, I noticed that the sfdx force:source:convert -d mdapioutput/ command only outputs the contents of the default path from my config.

  • did you ever figure this out? – NSjonas Dec 20 '17 at 4:12
3

If you run the command multiple times with the same output directly:

sfdx force:source:convert -r force-app -d mdapioutput/
sfdx force:source:convert -r http-sdk -d mdapioutput/

it does seem to merge the files correctly, but it does not properly merge the package.xml (will be overwritten with the last commands xml).

However, while undocumented, that you can put multiple packages under force-app and do something like this:

File Structure

- force-app
-- main
---- classes
---- pages
-- http-sdk
---- classes
---- pages

sfdx-project.json

{ ...
  "packageDirectories": [
    {
      "path": "force-app",
      "default": true
    },
    {
      "path": "force-app/main"
    },
    {
      "path": "force-app/http-sdk"
    }
  ],
...
}

You can then run: sfdx force:source:convert -r force-app -d mdapioutput/ to package both.

With this setup you can still package both individually:

sfdx force:source:convert -r force-app/http-sdk -d mdapioutput/

Disclaimer : I haven't tested this setup with scratch orgs so I'm not sure if force:source:pull and force:source:pull will work properly.

| improve this answer | |
1

You will need to indicate the root as well for the source convert

Have you tried below

sfdx force:source:convert -r http-sdk -d mdapioutput/
| improve this answer | |
  • Unfortunately it just uses that folder to copy the contents into the mdapioutput directory. I tried using -r http-sdk,force-app and that fails completely as it looks like it uses the -r argument to build just a single path. – Blake Oct 31 '17 at 22:50
  • I guess you will need to run convert command first with force-app and then with http-sdk for this . – Mohith Shrivastava Nov 1 '17 at 0:25

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.