hardis:packagexml:remove
Description
Command Behavior
Removes metadata components from a package.xml
file that are also present in another package.xml
file (e.g., a destructiveChanges.xml
).
This command is useful for refining your package.xml
manifests by excluding components that are being deleted or are otherwise irrelevant for a specific deployment or retrieval. For example, you can use it to create a package.xml
that only contains additions and modifications, by removing items listed in a destructiveChanges.xml
.
Key functionalities:
- Source
package.xml
: The mainpackage.xml
file from which components will be removed (specified by--packagexml
). Defaults topackage.xml
. - Filter
package.xml
: Thepackage.xml
file containing the components to be removed from the source (specified by--removepackagexml
). Defaults todestructiveChanges.xml
. - Output File: The path to the new
package.xml
file that will contain the filtered content (specified by--outputfile
). - Removed Only Output: The
--removedonly
flag allows you to generate apackage.xml
that contains only the items that were removed from the sourcepackage.xml
.
Technical explanations
The command's technical implementation involves:
- File Parsing: It reads and parses the XML content of both the source
package.xml
and the filterpackage.xml
. - Content Comparison and Filtering: It compares the metadata types and members defined in both files. Components found in the filter
package.xml
are excluded from the output. - XML Building: After filtering, it rebuilds the XML structure for the new
package.xml
file. - File Writing: The newly constructed XML content is then written to the specified output file.
removePackageXmlFilesContent
Utility: The core logic for this operation is encapsulated within theremovePackageXmlFilesContent
utility function, which handles the parsing, filtering, and writing of thepackage.xml
files.
Parameters
Name | Type | Description | Default | Required | Options |
---|---|---|---|---|---|
debug | boolean | debug | |||
flags-dir | option | undefined | |||
json | boolean | Format output as json. | |||
outputfile -f |
option | package.xml output file | |||
packagexml -p |
option | package.xml file to reduce | |||
removedonly -z |
boolean | Use this flag to generate a package.xml with only removed items | |||
removepackagexml -r |
option | package.xml file to use to filter input package.xml | |||
websocket | option | websocket |
Examples
$ sf hardis packagexml:remove -p package.xml -r destructiveChanges.xml -o my-reduced-package.xml