@ds-sfdc/sfparty 1.5.3 → 1.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/index.js +43 -24
- package/src/party/combine.js +15 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ds-sfdc/sfparty",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.5",
|
|
4
4
|
"description": "Salesforce metadata XML splitter for CI/CD",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@babel/core": "^7.24.4",
|
|
41
41
|
"@babel/preset-env": "^7.24.4",
|
|
42
|
-
"@commitlint/cli": "^19.2.
|
|
43
|
-
"@commitlint/config-conventional": "^19.
|
|
42
|
+
"@commitlint/cli": "^19.2.2",
|
|
43
|
+
"@commitlint/config-conventional": "^19.2.2",
|
|
44
44
|
"babel-jest": "^29.7.0",
|
|
45
45
|
"eslint": "^9.0.0",
|
|
46
46
|
"husky": "^9.0.11",
|
package/src/index.js
CHANGED
|
@@ -104,7 +104,7 @@ global.metaTypes = {
|
|
|
104
104
|
let types = []
|
|
105
105
|
const packageDir = getRootPath()
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
const errorMessage = clc.red(
|
|
108
108
|
'Please specify the action of ' +
|
|
109
109
|
clc.whiteBright.bgRedBright('split') +
|
|
110
110
|
' or ' +
|
|
@@ -193,7 +193,7 @@ yargs(hideBin(process.argv))
|
|
|
193
193
|
global.format = argv.format
|
|
194
194
|
const startProm = new Promise((resolve, reject) => {
|
|
195
195
|
if (argv.git !== undefined) {
|
|
196
|
-
|
|
196
|
+
const gitRef = argv.git.trim()
|
|
197
197
|
global.git.append = argv.append || global.git.append
|
|
198
198
|
global.git.delta = argv.delta || global.git.delta
|
|
199
199
|
if (argv.git === '') {
|
|
@@ -259,9 +259,9 @@ yargs(hideBin(process.argv))
|
|
|
259
259
|
global.git.enabled = result
|
|
260
260
|
|
|
261
261
|
if (global.git.enabled) {
|
|
262
|
-
|
|
262
|
+
const addManifest =
|
|
263
263
|
argv.package || 'manifest/package-party.xml'
|
|
264
|
-
|
|
264
|
+
const desManifest =
|
|
265
265
|
argv.destructive ||
|
|
266
266
|
'manifest/destructiveChanges-party.xml'
|
|
267
267
|
|
|
@@ -413,13 +413,13 @@ function yargCheck(argv, options) {
|
|
|
413
413
|
function displayMessageAndDuration(startTime, message) {
|
|
414
414
|
const diff = process.hrtime.bigint() - BigInt(startTime)
|
|
415
415
|
let durationMessage
|
|
416
|
-
|
|
417
|
-
|
|
416
|
+
const executionTime = convertHrtime(diff)
|
|
417
|
+
const minutes = Math.floor(
|
|
418
418
|
(executionTime.seconds +
|
|
419
419
|
Math.round(executionTime.milliseconds / 100000)) /
|
|
420
420
|
60,
|
|
421
421
|
)
|
|
422
|
-
|
|
422
|
+
const seconds = Math.round(
|
|
423
423
|
(executionTime.seconds +
|
|
424
424
|
Math.round(executionTime.milliseconds / 100000)) %
|
|
425
425
|
60,
|
|
@@ -453,7 +453,7 @@ function splitHandler(argv, startTime) {
|
|
|
453
453
|
splitHandler(argv, startTime)
|
|
454
454
|
} else {
|
|
455
455
|
if (argv.type === undefined || argv.type.split(',').length > 1) {
|
|
456
|
-
|
|
456
|
+
const message = `Split completed in `
|
|
457
457
|
displayMessageAndDuration(startTime, message)
|
|
458
458
|
}
|
|
459
459
|
checkVersion({
|
|
@@ -488,7 +488,7 @@ function processSplit(typeItem, argv) {
|
|
|
488
488
|
let sourceDir = argv.source || ''
|
|
489
489
|
let targetDir = argv.target || ''
|
|
490
490
|
let name = argv.name
|
|
491
|
-
|
|
491
|
+
const all =
|
|
492
492
|
argv.type === undefined || name === undefined ? true : argv.all
|
|
493
493
|
|
|
494
494
|
if (type == global.metaTypes.label.type) {
|
|
@@ -517,7 +517,7 @@ function processSplit(typeItem, argv) {
|
|
|
517
517
|
typeObj.definition.directory,
|
|
518
518
|
)
|
|
519
519
|
}
|
|
520
|
-
|
|
520
|
+
const metaDirPath = sourceDir
|
|
521
521
|
|
|
522
522
|
if (!all) {
|
|
523
523
|
let metaFilePath = path.join(metaDirPath, name)
|
|
@@ -570,19 +570,23 @@ function processSplit(typeItem, argv) {
|
|
|
570
570
|
})
|
|
571
571
|
})
|
|
572
572
|
Promise.allSettled(promList).then((results) => {
|
|
573
|
-
|
|
573
|
+
const message = `Split ${clc.bgBlackBright(
|
|
574
574
|
processed.current > promList.length
|
|
575
575
|
? promList.length
|
|
576
576
|
: processed.current,
|
|
577
577
|
)} file(s) ${
|
|
578
578
|
processed.errors > 0
|
|
579
579
|
? 'with ' +
|
|
580
|
-
|
|
581
|
-
|
|
580
|
+
clc.bgBlackBright.red(processed.errors) +
|
|
581
|
+
' error(s) '
|
|
582
582
|
: ''
|
|
583
583
|
}in `
|
|
584
584
|
displayMessageAndDuration(startTime, message)
|
|
585
|
-
|
|
585
|
+
if (errors > 0) {
|
|
586
|
+
resolve(false)
|
|
587
|
+
} else {
|
|
588
|
+
resolve(true)
|
|
589
|
+
}
|
|
586
590
|
})
|
|
587
591
|
})
|
|
588
592
|
}
|
|
@@ -590,6 +594,12 @@ function processSplit(typeItem, argv) {
|
|
|
590
594
|
function combineHandler(argv, startTime) {
|
|
591
595
|
const combine = processCombine(types[0], argv)
|
|
592
596
|
combine.then((resolve) => {
|
|
597
|
+
if (resolve == false) {
|
|
598
|
+
global.logger.error(
|
|
599
|
+
'Will not continue due to YAML format issues. Please correct and try again.',
|
|
600
|
+
)
|
|
601
|
+
process.exit(1)
|
|
602
|
+
}
|
|
593
603
|
types.shift() // remove first item from array
|
|
594
604
|
if (types.length > 0) {
|
|
595
605
|
console.log()
|
|
@@ -608,7 +618,7 @@ function combineHandler(argv, startTime) {
|
|
|
608
618
|
desPkg.savePackage(xml2js, fileUtils)
|
|
609
619
|
}
|
|
610
620
|
if (argv.type === undefined || argv.type.split(',').length > 1) {
|
|
611
|
-
|
|
621
|
+
const message = `Combine completed in `
|
|
612
622
|
displayMessageAndDuration(startTime, message)
|
|
613
623
|
}
|
|
614
624
|
checkVersion({
|
|
@@ -644,8 +654,8 @@ function processCombine(typeItem, argv) {
|
|
|
644
654
|
|
|
645
655
|
let sourceDir = argv.source || ''
|
|
646
656
|
let targetDir = argv.target || ''
|
|
647
|
-
|
|
648
|
-
|
|
657
|
+
const name = argv.name
|
|
658
|
+
const all =
|
|
649
659
|
argv.type === undefined || name === undefined ? true : argv.all
|
|
650
660
|
|
|
651
661
|
sourceDir = path.join(
|
|
@@ -685,7 +695,7 @@ function processCombine(typeItem, argv) {
|
|
|
685
695
|
processList.push(global.metaTypes.label.definition.root)
|
|
686
696
|
}
|
|
687
697
|
} else if (!all) {
|
|
688
|
-
|
|
698
|
+
const metaDirPath = path.join(sourceDir, name)
|
|
689
699
|
if (!fileUtils.directoryExists({ dirPath: metaDirPath, fs })) {
|
|
690
700
|
global.logger.error('Directory not found: ' + metaDirPath)
|
|
691
701
|
process.exit(1)
|
|
@@ -747,17 +757,26 @@ function processCombine(typeItem, argv) {
|
|
|
747
757
|
results.forEach((result) => {
|
|
748
758
|
if (result.value == true) {
|
|
749
759
|
successes++
|
|
750
|
-
} else if (
|
|
760
|
+
} else if (
|
|
761
|
+
result.value == false ||
|
|
762
|
+
result.status == 'rejected'
|
|
763
|
+
) {
|
|
751
764
|
errors++
|
|
752
765
|
}
|
|
753
766
|
})
|
|
754
|
-
|
|
767
|
+
const message = `Combined ${clc.bgBlackBright(successes)} file(s) ${
|
|
755
768
|
errors > 0
|
|
756
|
-
? 'with ' +
|
|
769
|
+
? 'with ' +
|
|
770
|
+
clc.bgBlackBright.red(processed.errors) +
|
|
771
|
+
' error(s) '
|
|
757
772
|
: ''
|
|
758
773
|
}in `
|
|
759
774
|
displayMessageAndDuration(startTime, message)
|
|
760
|
-
|
|
775
|
+
if (errors > 0) {
|
|
776
|
+
resolve(false)
|
|
777
|
+
} else {
|
|
778
|
+
resolve(true)
|
|
779
|
+
}
|
|
761
780
|
})
|
|
762
781
|
})
|
|
763
782
|
}
|
|
@@ -839,7 +858,7 @@ function displayHeader() {
|
|
|
839
858
|
horizontal: '─',
|
|
840
859
|
vertical: '│',
|
|
841
860
|
}
|
|
842
|
-
|
|
861
|
+
const versionString = `sfparty v${pkgObj.version}${
|
|
843
862
|
process.stdout.columns > pkgObj.description.length + 15
|
|
844
863
|
? ' - ' + pkgObj.description
|
|
845
864
|
: ''
|
|
@@ -876,7 +895,7 @@ function displayHeader() {
|
|
|
876
895
|
}
|
|
877
896
|
|
|
878
897
|
function getRootPath(packageDir) {
|
|
879
|
-
|
|
898
|
+
const rootPath = fileUtils.find('sfdx-project.json')
|
|
880
899
|
let defaultDir
|
|
881
900
|
if (rootPath) {
|
|
882
901
|
global.__basedir = fileUtils.fileInfo(rootPath).dirname
|
package/src/party/combine.js
CHANGED
|
@@ -149,7 +149,7 @@ export class Combine {
|
|
|
149
149
|
const success = processParts(that)
|
|
150
150
|
// Ensure we only match existing metadata type directory and item
|
|
151
151
|
|
|
152
|
-
if (success) {
|
|
152
|
+
if (success === true) {
|
|
153
153
|
if (
|
|
154
154
|
!that.metadataDefinition.packageTypeIsDirectory &&
|
|
155
155
|
global.git.enabled
|
|
@@ -171,6 +171,12 @@ export class Combine {
|
|
|
171
171
|
}
|
|
172
172
|
saveXML(that)
|
|
173
173
|
return true
|
|
174
|
+
} else if (
|
|
175
|
+
success &&
|
|
176
|
+
success.name &&
|
|
177
|
+
success.name == 'YAMLException'
|
|
178
|
+
) {
|
|
179
|
+
throw error
|
|
174
180
|
} else {
|
|
175
181
|
logUpdate(
|
|
176
182
|
that.#spinnerMessage
|
|
@@ -279,6 +285,8 @@ export class Combine {
|
|
|
279
285
|
} catch (error) {
|
|
280
286
|
if (error.message == 'delete XML') {
|
|
281
287
|
return false
|
|
288
|
+
} else if (error.name == 'YAMLException') {
|
|
289
|
+
throw error
|
|
282
290
|
} else {
|
|
283
291
|
return true
|
|
284
292
|
}
|
|
@@ -469,7 +477,12 @@ export class Combine {
|
|
|
469
477
|
) {
|
|
470
478
|
return true
|
|
471
479
|
}
|
|
472
|
-
let result
|
|
480
|
+
let result
|
|
481
|
+
try {
|
|
482
|
+
result = fileUtils.readFile(fileObj.fullName)
|
|
483
|
+
} catch (error) {
|
|
484
|
+
throw error
|
|
485
|
+
}
|
|
473
486
|
if (
|
|
474
487
|
fileObj.fullName ==
|
|
475
488
|
path.join(
|