@ds-sfdc/sfparty 1.5.3 → 1.5.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ds-sfdc/sfparty",
3
- "version": "1.5.3",
3
+ "version": "1.5.4",
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.1",
43
- "@commitlint/config-conventional": "^19.1.0",
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
- let errorMessage = clc.red(
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
- let gitRef = argv.git.trim()
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
- let addManifest =
262
+ const addManifest =
263
263
  argv.package || 'manifest/package-party.xml'
264
- let desManifest =
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
- let executionTime = convertHrtime(diff)
417
- let minutes = Math.floor(
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
- let seconds = Math.round(
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
- let message = `Split completed in `
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
- let all =
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
- let metaDirPath = sourceDir
520
+ const metaDirPath = sourceDir
521
521
 
522
522
  if (!all) {
523
523
  let metaFilePath = path.join(metaDirPath, name)
@@ -570,15 +570,15 @@ function processSplit(typeItem, argv) {
570
570
  })
571
571
  })
572
572
  Promise.allSettled(promList).then((results) => {
573
- let message = `Split ${clc.bgBlackBright(
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
- clc.bgBlackBright.red(processed.errors) +
581
- ' error(s) '
580
+ clc.bgBlackBright.red(processed.errors) +
581
+ ' error(s) '
582
582
  : ''
583
583
  }in `
584
584
  displayMessageAndDuration(startTime, message)
@@ -590,6 +590,12 @@ function processSplit(typeItem, argv) {
590
590
  function combineHandler(argv, startTime) {
591
591
  const combine = processCombine(types[0], argv)
592
592
  combine.then((resolve) => {
593
+ if (resolve == false) {
594
+ global.logger.error(
595
+ 'Will not continue due to YAML format issues. Please correct and try again.',
596
+ )
597
+ process.exit(1)
598
+ }
593
599
  types.shift() // remove first item from array
594
600
  if (types.length > 0) {
595
601
  console.log()
@@ -608,7 +614,7 @@ function combineHandler(argv, startTime) {
608
614
  desPkg.savePackage(xml2js, fileUtils)
609
615
  }
610
616
  if (argv.type === undefined || argv.type.split(',').length > 1) {
611
- let message = `Combine completed in `
617
+ const message = `Combine completed in `
612
618
  displayMessageAndDuration(startTime, message)
613
619
  }
614
620
  checkVersion({
@@ -644,8 +650,8 @@ function processCombine(typeItem, argv) {
644
650
 
645
651
  let sourceDir = argv.source || ''
646
652
  let targetDir = argv.target || ''
647
- let name = argv.name
648
- let all =
653
+ const name = argv.name
654
+ const all =
649
655
  argv.type === undefined || name === undefined ? true : argv.all
650
656
 
651
657
  sourceDir = path.join(
@@ -685,7 +691,7 @@ function processCombine(typeItem, argv) {
685
691
  processList.push(global.metaTypes.label.definition.root)
686
692
  }
687
693
  } else if (!all) {
688
- let metaDirPath = path.join(sourceDir, name)
694
+ const metaDirPath = path.join(sourceDir, name)
689
695
  if (!fileUtils.directoryExists({ dirPath: metaDirPath, fs })) {
690
696
  global.logger.error('Directory not found: ' + metaDirPath)
691
697
  process.exit(1)
@@ -747,17 +753,24 @@ function processCombine(typeItem, argv) {
747
753
  results.forEach((result) => {
748
754
  if (result.value == true) {
749
755
  successes++
750
- } else if (result.value == false) {
756
+ } else if (
757
+ result.value == false ||
758
+ result.status == 'rejected'
759
+ ) {
751
760
  errors++
752
761
  }
753
762
  })
754
- let message = `Combined ${clc.bgBlackBright(successes)} file(s) ${
763
+ const message = `Combined ${clc.bgBlackBright(successes)} file(s) ${
755
764
  errors > 0
756
- ? 'with ' + clc.bgBlackBright(errors) + 'error(s) '
765
+ ? 'with ' + clc.bgBlackBright(errors) + ' error(s) '
757
766
  : ''
758
767
  }in `
759
768
  displayMessageAndDuration(startTime, message)
760
- resolve(true)
769
+ if (successes == 0 && errors > 0) {
770
+ resolve(false)
771
+ } else {
772
+ resolve(true)
773
+ }
761
774
  })
762
775
  })
763
776
  }
@@ -839,7 +852,7 @@ function displayHeader() {
839
852
  horizontal: '─',
840
853
  vertical: '│',
841
854
  }
842
- let versionString = `sfparty v${pkgObj.version}${
855
+ const versionString = `sfparty v${pkgObj.version}${
843
856
  process.stdout.columns > pkgObj.description.length + 15
844
857
  ? ' - ' + pkgObj.description
845
858
  : ''
@@ -876,7 +889,7 @@ function displayHeader() {
876
889
  }
877
890
 
878
891
  function getRootPath(packageDir) {
879
- let rootPath = fileUtils.find('sfdx-project.json')
892
+ const rootPath = fileUtils.find('sfdx-project.json')
880
893
  let defaultDir
881
894
  if (rootPath) {
882
895
  global.__basedir = fileUtils.fileInfo(rootPath).dirname
@@ -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 = fileUtils.readFile(fileObj.fullName)
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(