AnswerBun.com

Ignore files when force:source:convert

Salesforce Asked by Simonp on January 6, 2022

My scratch orgs have this feature:

"features": ["DebugApex"],

So I create a PermissionSet enable this feature on the scratch org. But when running sfdx force:source:convert --outputdir mdapi_output --packagename packageName the permission set is included and is causing failure when pushing on an org for packaging (sfdx force:mdapi:deploy --deploydir mdapi_output -u XXX).

Is there a way to exclude it from packaging ? forceignore file excludes it from pull/push on scratch and it is not the goal.

4 Answers

Create a directory structure like donotconvert/main/default/permissionsets/ and move your debug apex permset under there. Add the donotconvert directory to the list of packageDirectories in sfdx-project.json. Now when you run force:source:convert specify the directory structure to convert using the -r parameter.

Answered by Suraj on January 6, 2022

My read of the documentation is that the .forceignore file mentioned by others is only when you're pushing and pulling to the scratch org or converting from mdapi TO DX, not the other way around.

For our team where we just ran into this, I'm writing a bash script (but it could be written in anything) that will copy the DX force-app code tree to something like mdapimidway, prune out the files we don't want to convert and deploy and then call the convert command with the midway tree as the source to convert

sfdx force:source:convert -r mdapimidway/ -d mdapioutput/

The real power of DX isn't that it has functional parity with other tools, it's that you can throw it into the middle of your own scripts to take care of all the things they didn't think of.

Answered by Dave Lyon on January 6, 2022

Use .forceignore. As stated in the documentation:

When syncing metadata between your local file system and a scratch org, you often have source files you want to exclude. Similarly, you often want to exclude certain files when converting source to Salesforce DX project format. In both cases, you can exclude individual files or all files in a specific directory with a .forceignore file. (Emphasis added.)

Answered by sfdcfox on January 6, 2022

Just had the same sort of problem and didn't find a mechanism in SFDX for this sort of filtering.

We are using Ant as well as SFDX and that has good filtering mechanisms (and we also have files split into separate trees so need to merge those trees) so we are first copying to a new tree of files where the files we don't want are excluded and then running the convert:

<target name="clean">
    <delete dir="./mdapi-source/staged"/>
    <delete dir="./mdapi-source/cvux"/>
</target>

<target name="convert" depends="clean">
    <copy todir="./mdapi-source/staged">
        <fileset dir="./sfdx-source/int/test"/>
        <fileset dir="./sfdx-source/int/main"/>
        <fileset dir="./sfdx-source/wiz/test">
           <exclude name="**/aura/**"/>
           <exclude name="**/staticresources/**"/>
        </fileset>
        <fileset dir="./sfdx-source/wiz/main"/>
    </copy>
    <exec dir="." executable="sfdx" osfamily="unix" failonerror="true">
        <arg value="force:source:convert"/>
        <arg value="--rootdir" />
        <arg value="./mdapi-source/staged" />
        <arg value="--outputdir" />
        <arg value="./mdapi-source/cvux" />
    </exec>
</target>

There might be something that helps in the sfdx-isv/sfdx-falcon-template project that:

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).

Answered by Keith C on January 6, 2022

Add your own answers!

Related Questions

Create lead if contact does not exist live agent

2  Asked on November 20, 2020 by c0depirate

   

How to capture URL parameters

1  Asked on November 12, 2020 by devforce

       

lightning:carousel error

1  Asked on November 3, 2020 by sankhadeep-biswas

   

Hide Case Owner Field in Recently View Cases List view

1  Asked on October 27, 2020 by chaithra-k-n

   

Calling REST APIs from PHP with curl

1  Asked on October 9, 2020 by mike-lacourse

     

how to Get API Server Name in Apex code

4  Asked on September 16, 2020

   

Ask a Question

Get help from others!

© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir