|
| 1 | +import * as fs from 'fs'; |
| 2 | +import * as path from 'path'; |
| 3 | + |
| 4 | +// Method to generate package.xml with additional types |
| 5 | +function createChangeList(apexClasses: string[], lwcComponents: string[]): void { |
| 6 | + const apexXml = apexClasses.map((name) => `<members>${name}</members>`).join('\n '); |
| 7 | + const lwcXml = lwcComponents.map((name) => `<members>${name}</members>`).join('\n '); |
| 8 | + |
| 9 | + const additionalTypes = ` |
| 10 | + <types> |
| 11 | + <members>*</members> |
| 12 | + <name>OmniDataTransform</name> |
| 13 | + </types> |
| 14 | + <types> |
| 15 | + <members>*</members> |
| 16 | + <name>OmniIntegrationProcedure</name> |
| 17 | + </types> |
| 18 | + <types> |
| 19 | + <members>*</members> |
| 20 | + <name>OmniScript</name> |
| 21 | + </types> |
| 22 | + <types> |
| 23 | + <members>*</members> |
| 24 | + <name>OmniUiCard</name> |
| 25 | + </types> |
| 26 | + `; |
| 27 | + |
| 28 | + const packageXmlContent = ` |
| 29 | +<?xml version="1.0" encoding="UTF-8"?> |
| 30 | +<Package xmlns="http://soap.sforce.com/2006/04/metadata"> |
| 31 | + <types> |
| 32 | + ${apexXml} |
| 33 | + <name>ApexClass</name> |
| 34 | + </types> |
| 35 | + <types> |
| 36 | + ${lwcXml} |
| 37 | + <name>LightningComponentBundle</name> |
| 38 | + </types> |
| 39 | + ${additionalTypes} |
| 40 | + <version>57.0</version> |
| 41 | +</Package> |
| 42 | +`; |
| 43 | + |
| 44 | + const filePath = path.join(__dirname, 'package.xml'); |
| 45 | + fs.writeFileSync(filePath, packageXmlContent.trim()); |
| 46 | +} |
| 47 | + |
| 48 | +// Backup method without additional types |
| 49 | +function backupChangeList(apexClasses: string[], lwcComponents: string[]): void { |
| 50 | + const apexXml = apexClasses.map((name) => `<members>${name}</members>`).join('\n '); |
| 51 | + const lwcXml = lwcComponents.map((name) => `<members>${name}</members>`).join('\n '); |
| 52 | + |
| 53 | + const packageXmlContent = ` |
| 54 | +<?xml version="1.0" encoding="UTF-8"?> |
| 55 | +<Package xmlns="http://soap.sforce.com/2006/04/metadata"> |
| 56 | + <types> |
| 57 | + ${apexXml} |
| 58 | + <name>ApexClass</name> |
| 59 | + </types> |
| 60 | + <types> |
| 61 | + ${lwcXml} |
| 62 | + <name>LightningComponentBundle</name> |
| 63 | + </types> |
| 64 | + <version>57.0</version> |
| 65 | +</Package> |
| 66 | +`; |
| 67 | + |
| 68 | + const filePath = path.join(__dirname, 'backup-package.xml'); |
| 69 | + fs.writeFileSync(filePath, packageXmlContent.trim()); |
| 70 | +} |
| 71 | + |
| 72 | +// remove all this code later --- only for testing |
| 73 | +const apexClasses = ['MyApexClass1', 'MyApexClass2']; |
| 74 | +const lwcComponents = ['MyLwcComponent1', 'MyLwcComponent2']; |
| 75 | + |
| 76 | +// creating normal package.xml with additional types |
| 77 | +createChangeList(apexClasses, lwcComponents); |
| 78 | + |
| 79 | +// creating backup-package.xml without additional types |
| 80 | +backupChangeList(apexClasses, lwcComponents); |
0 commit comments