https://github.com/mcarvin8/sf-package-combiner
Combine multiple Salesforce manifest files (package.xml) into 1 file for deployments.
https://github.com/mcarvin8/sf-package-combiner
continuous-deployment deployment manifest salesforce
Last synced: 22 days ago
JSON representation
Combine multiple Salesforce manifest files (package.xml) into 1 file for deployments.
- Host: GitHub
- URL: https://github.com/mcarvin8/sf-package-combiner
- Owner: mcarvin8
- License: mit
- Created: 2024-11-08T03:26:24.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2025-04-01T13:30:46.000Z (about 1 month ago)
- Last Synced: 2025-04-01T14:26:49.582Z (about 1 month ago)
- Topics: continuous-deployment, deployment, manifest, salesforce
- Language: TypeScript
- Homepage:
- Size: 412 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# `sf-package-combiner`
[](https://www.npmjs.com/package/sf-package-combiner) [](https://npmjs.org/package/sf-package-combiner) [](https://raw.githubusercontent.com/mcarvin8/sf-package-combiner/refs/heads/main/LICENSE.md)
Table of Contents
- [Install](#install)
- [Command](#command)
- [`sf-sfpc-combine`](#sf-sfpc-combine)
- [Usage](#usage)
- [Manifest Structure](#manifest-structure)
- [Example](#example)
- [Issues](#issues)
- [License](#license)**Combine multiple Salesforce `package.xml` files into a single manifest** for deployments. This is useful when:
- Using tools like `sfdx-git-delta` to generate incremental package.xml files
- Merging different package.xml files from various sources
- Ensuring a streamlined deployment process in CI/CD workflows## Install
```bash
sf plugins install [email protected]
```## Command
- [`sf sfpc combine`](#sf-sfpc-combine)
## `sf sfpc combine`
Combine Salesforce manifest files together.
```
USAGE
$ sf sfpc combine [-f ] [-d ] [-c ] [-v ] [-n] [--json]FLAGS
-f, --package-file= The path to an existing package.xml file.
Can be specified multiple times.
-d, --directory= The path to an existing directory with package.xml files.
Can be specified multiple times.
-v, --api-version= Specify the API version (e.g., '62.0') to use in the combined package.xml.
-n, --no-api-version Intentionally omit the API version in the combined package.xml.
-c, --combined-package= The path to save the combined package.xml to.
If this value matches one of the input packages, it will overwrite the file.
Default is "package.xml".GLOBAL FLAGS
--json Format output as json.DESCRIPTION
Combine multiple package files into 1 file.EXAMPLES
Combine pack1.xml and pack2.xml into package.xml$ sf sfpc combine -f pack1.xml -f pack2.xml -c package.xml
Combine pack1.xml, pack2.xml, and all package XML files in a directory into package.xml
$ sf sfpc combine -f pack1.xml -f pack2.xml -d "test/sample_dir" -c package.xml
Combine pack1.xml and pack2.xml into package.xml set at API version 62.0
$ sf sfpc combine -f pack1.xml -f pack2.xml -v "62.0" -c package.xml
Combine pack1.xml and pack2.xml into package.xml with no API version declared
$ sf sfpc combine -f pack1.xml -f pack2.xml -n -c package.xml
```## Usage
### How it Works
- The `` elements (metadata types) are **converted to lowercase** to ensure consistency and avoid duplicates.
- The `` elements **retain their original case**, as Salesforce treats them as case-sensitive.
- By default, the **highest API version** found in the input manifests is used.
- If no `` tag is found, it is omitted from the final `package.xml`.**To override the API version behavior:**
- Use `-v ` to **set a specific API version**.
- Use `-n` to **omit the API version entirely**.### Handling Invalid `package.xml` Files
If a file doesn't match the expected [structure](#manifest-structure) or has no `` in it, it is skipped with a warning:
```plaintext
Warning: Invalid or empty package.xml: .\test\samples\invalid2.xml
```If all packages are invalid or empty, the combined package.xml will be an empty package (no ``). You can avoid deploying an empty package by searching the manifest for any `` in it before running the deploy command.
```bash
sf sfpc combine -f "package/package.xml" -f "package.xml" -c "package.xml"
if grep -q '' ./package.xml ; then
echo "---- Deploying added and modified metadata ----"
sf project deploy start -x package.xml
else
echo "---- No changes to deploy ----"
fi
```---
## Manifest Structure
Salesforce `package.xml` files follow this structure:
- **Root:** ``
- **Metadata Types:** `` contains:
- ``: Lists metadata item(s) via their API names.
- ``: Metadata type (e.g., `ApexClass`, `CustomObject`).
- **API Version (Optional):** `` specifies the metadata API version.## Example
### Inputs
#### `package1.xml`
```xml
MyApexClass
ApexClass
60.0```
#### `package2.xml`
```xml
MyTrigger
ApexTrigger
62.0```
### Command
```bash
sf sfpc combine -f "package1.xml" -f "package2.xml" -c "package.xml"
```### Output (`package.xml`)
```xml
MyApexClass
apexclass
MyTrigger
apextrigger
62.0```
## Issues
If you encounter any issues or would like to suggest features, please create an [issue](https://github.com/mcarvin8/sf-package-combiner/issues).
## License
This project is licensed under the MIT license. Please see the [LICENSE](https://raw.githubusercontent.com/mcarvin8/sf-package-combiner/main/LICENSE.md) file for details.