@ds-sfdc/sfparty 1.2.1 → 1.2.2

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.
@@ -1,6 +1,6 @@
1
1
  labels:
2
2
  fullName: Description
3
- shortDescription: Description
3
+ shortDescription: Test
4
4
  categories: description,sfparty
5
5
  protected: true
6
6
  language: en_US
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ds-sfdc/sfparty",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "Salesforce metadata XML splitter for CI/CD",
5
5
  "type": "module",
6
6
  "repository": {
package/src/index.js CHANGED
@@ -27,7 +27,7 @@ global.logger = winston.createLogger({
27
27
  transports: [
28
28
  new winston.transports.Console(),
29
29
  ],
30
- });
30
+ })
31
31
 
32
32
  global.icons = {
33
33
  "warn": '🔕',
@@ -97,7 +97,7 @@ function getDirectories() {
97
97
  const types = []
98
98
  Object.keys(global.metaTypes).forEach(type => {
99
99
  try {
100
- types.push(global.metaTypes[type].definition.directory)
100
+ types.push(global.metaTypes[type].definition.directory)
101
101
  } catch (error) {
102
102
  throw error
103
103
  }
@@ -148,14 +148,14 @@ function displayHeader() {
148
148
  horizontal: '─',
149
149
  vertical: '│',
150
150
  }
151
- let versionString = `sfparty v${pkgObj.default.version}${(process.stdout.columns > pkgObj.default.description.length + 15) ? ' - ' + pkgObj.default.description : ''}`
152
- let titleMessage = `${global.icons.party} ${chalk.yellowBright(versionString)} ${global.icons.party}`
151
+ let versionString = `sfparty v${ pkgObj.default.version }${ (process.stdout.columns > pkgObj.default.description.length + 15) ? ' - ' + pkgObj.default.description : '' }`
152
+ let titleMessage = `${ global.icons.party } ${ chalk.yellowBright(versionString) } ${ global.icons.party }`
153
153
  titleMessage = titleMessage.padEnd((process.stdout.columns / 2) + versionString.length / 1.65)
154
154
  titleMessage = titleMessage.padStart(process.stdout.columns)
155
155
  titleMessage = chalk.blackBright(box.vertical) + ' ' + titleMessage + ' ' + chalk.blackBright(box.vertical)
156
- console.log(`${chalk.blackBright(box.topLeft + box.horizontal.repeat(process.stdout.columns - 2) + box.topRight)}`)
156
+ console.log(`${ chalk.blackBright(box.topLeft + box.horizontal.repeat(process.stdout.columns - 2) + box.topRight) }`)
157
157
  console.log(titleMessage)
158
- console.log(`${chalk.blackBright(box.bottomLeft + box.horizontal.repeat(process.stdout.columns - 2) + box.bottomRight)}`)
158
+ console.log(`${ chalk.blackBright(box.bottomLeft + box.horizontal.repeat(process.stdout.columns - 2) + box.bottomRight) }`)
159
159
  console.log()
160
160
  }
161
161
 
@@ -166,7 +166,7 @@ yargs(hideBin(process.argv))
166
166
  alias: 'test',
167
167
  handler: (argv) => {
168
168
  // THIS IS A PLACE TO TEST NEW CODE
169
- global.logger.info(chalk.magentaBright(`${global.icons.party} TEST ${global.icons.party}`))
169
+ global.logger.info(chalk.magentaBright(`${ global.icons.party } TEST ${ global.icons.party }`))
170
170
  }
171
171
  })
172
172
  .command({
@@ -208,12 +208,12 @@ yargs(hideBin(process.argv))
208
208
  global.git.latest = data.latest
209
209
  global.git.last = data.last
210
210
  if (data.last === undefined) {
211
- console.log(`${chalk.yellowBright('git mode')} ${chalk.bgMagentaBright('not active:')} no prior commit - processing all`)
211
+ console.log(`${ chalk.yellowBright('git mode') } ${ chalk.bgMagentaBright('not active:') } no prior commit - processing all`)
212
212
  resolve(false)
213
213
  } else {
214
- console.log(`${chalk.yellowBright('git mode')} ${chalk.magentaBright('active:')} ${chalk.bgBlackBright(data.last) + '..' + chalk.bgBlackBright(data.latest)}`)
214
+ console.log(`${ chalk.yellowBright('git mode') } ${ chalk.magentaBright('active:') } ${ chalk.bgBlackBright(data.last) + '..' + chalk.bgBlackBright(data.latest) }`)
215
215
  console.log()
216
- const diff = git.diff(global.__basedir, `${data.last}..${data.latest}`)
216
+ const diff = git.diff(global.__basedir, `${ data.last }..${ data.latest }`)
217
217
  diff
218
218
  .then((data, error) => {
219
219
  gitFiles(data)
@@ -222,14 +222,15 @@ yargs(hideBin(process.argv))
222
222
  .catch((error) => {
223
223
  global.logger.error(error)
224
224
  reject(error)
225
- }) }
225
+ })
226
+ }
226
227
  })
227
228
  .catch((error) => {
228
229
  global.logger.error(error)
229
230
  throw error
230
231
  })
231
232
  } else {
232
- console.log(`${chalk.yellowBright('git mode')} ${chalk.magentaBright('active:')} ${chalk.bgBlackBright(gitRef)}`)
233
+ console.log(`${ chalk.yellowBright('git mode') } ${ chalk.magentaBright('active:') } ${ chalk.bgBlackBright(gitRef) }`)
233
234
  console.log()
234
235
  const diff = git.diff(global.__basedir, gitRef)
235
236
  diff
@@ -271,7 +272,7 @@ function yargCheck(argv, options) {
271
272
  types.forEach(type => {
272
273
  type = type.trim()
273
274
  if (!typeArray.includes(type)) {
274
- throw new Error(`Invalid type: ${type}`)
275
+ throw new Error(`Invalid type: ${ type }`)
275
276
  }
276
277
  })
277
278
 
@@ -295,27 +296,27 @@ function yargCheck(argv, options) {
295
296
  function displayMessageAndDuration(startTime, message) {
296
297
  const diff = process.hrtime.bigint() - BigInt(startTime)
297
298
  let durationMessage
298
- let executionTime = convertHrtime(diff);
299
+ let executionTime = convertHrtime(diff)
299
300
  let minutes = Math.floor((executionTime.seconds + Math.round(executionTime.milliseconds / 100000)) / 60)
300
301
  let seconds = Math.round((executionTime.seconds + Math.round(executionTime.milliseconds / 100000)) % 60)
301
302
  if (minutes == 0 && seconds == 0) {
302
303
  durationMessage = message + chalk.magentaBright(`<1s`)
303
304
  } else if (minutes > 0) {
304
- durationMessage = message + chalk.magentaBright(`${minutes}m ${seconds}s`)
305
+ durationMessage = message + chalk.magentaBright(`${ minutes }m ${ seconds }s`)
305
306
  } else {
306
- durationMessage = message + chalk.magentaBright(`${seconds}s`)
307
+ durationMessage = message + chalk.magentaBright(`${ seconds }s`)
307
308
  }
308
309
  console.log('\n' + durationMessage)
309
310
  }
310
311
 
311
- let callAmount = 0;
312
+ let callAmount = 0
312
313
  process.on('SIGINT', function () {
313
314
  if (callAmount < 1) {
314
- console.log(`✅ Received abort command`);
315
+ console.log(`✅ Received abort command`)
315
316
  process.exit(1)
316
317
  }
317
318
 
318
- callAmount++;
319
+ callAmount++
319
320
  })
320
321
 
321
322
  function splitHandler(argv, startTime) {
@@ -351,7 +352,7 @@ function processSplit(typeItem, argv) {
351
352
  const fileList = []
352
353
  const typeObj = global.metaTypes[typeItem]
353
354
  const type = typeObj.type
354
- const metaExtension = `.${type}-meta.xml`
355
+ const metaExtension = `.${ type }-meta.xml`
355
356
 
356
357
  let sourceDir = argv.source || ''
357
358
  let targetDir = argv.target || ''
@@ -391,11 +392,11 @@ function processSplit(typeItem, argv) {
391
392
  processed.total = fileList.length
392
393
 
393
394
  if (processed.total == 0) resolve(true)
394
-
395
- console.log(`${chalk.bgBlackBright('Source path:')} ${sourceDir}`)
396
- console.log(`${chalk.bgBlackBright('Target path:')} ${targetDir}`)
395
+
396
+ console.log(`${ chalk.bgBlackBright('Source path:') } ${ sourceDir }`)
397
+ console.log(`${ chalk.bgBlackBright('Target path:') } ${ targetDir }`)
397
398
  console.log()
398
- console.log(`Splitting a total of ${processed.total} file(s)`)
399
+ console.log(`Splitting a total of ${ processed.total } file(s)`)
399
400
  console.log()
400
401
 
401
402
  const promList = []
@@ -420,7 +421,7 @@ function processSplit(typeItem, argv) {
420
421
  })
421
422
  })
422
423
  Promise.allSettled(promList).then((results) => {
423
- let message = `Split ${chalk.bgBlackBright((processed.current > promList.length) ? promList.length : processed.current)} file(s) ${(processed.errors > 0) ? 'with ' + chalk.bgBlackBright.red(processed.errors) + ' error(s) ' : ''}in `
424
+ let message = `Split ${ chalk.bgBlackBright((processed.current > promList.length) ? promList.length : processed.current) } file(s) ${ (processed.errors > 0) ? 'with ' + chalk.bgBlackBright.red(processed.errors) + ' error(s) ' : '' }in `
424
425
  displayMessageAndDuration(startTime, message)
425
426
  resolve(true)
426
427
  })
@@ -477,10 +478,10 @@ function processCombine(typeItem, argv) {
477
478
  targetDir = path.join(targetDir, 'main', 'default', typeObj.definition.directory)
478
479
  }
479
480
 
480
-
481
+
481
482
 
482
483
  if (type == global.metaTypes.label.type) {
483
- if (!global.git.enabled || global.metaTypes.label.add.directories.includes(global.metaTypes.label.definition.root)) {
484
+ if (!global.git.enabled || [...new Set([...global.metaTypes.label.add.directories, ...global.metaTypes.label.remove.directories])].includes(global.metaTypes.label.definition.root)) {
484
485
  processList.push(global.metaTypes.label.definition.root)
485
486
  }
486
487
  } else if (!all) {
@@ -492,7 +493,7 @@ function processCombine(typeItem, argv) {
492
493
  processList.push(name)
493
494
  } else {
494
495
  if (global.git.enabled) {
495
- processList = global.metaTypes[typeItem].add.directories
496
+ processList = [...new Set([...global.metaTypes.label.add.directories, ...global.metaTypes.label.remove.directories])]
496
497
  } else {
497
498
  processList = fileUtils.getDirectories(sourceDir)
498
499
  }
@@ -502,15 +503,15 @@ function processCombine(typeItem, argv) {
502
503
 
503
504
  // Abort if there are no files to process
504
505
  if (processed.total == 0) {
505
- console.log(`${chalk.bgBlackBright('0')} ${typeItem} files to process`)
506
+ console.log(`${ chalk.bgBlackBright('0') } ${ typeItem } files to process`)
506
507
  resolve(true)
507
508
  return
508
509
  }
509
510
 
510
- console.log(`${chalk.bgBlackBright('Source path:')} ${sourceDir}`)
511
- console.log(`${chalk.bgBlackBright('Target path:')} ${targetDir}`)
511
+ console.log(`${ chalk.bgBlackBright('Source path:') } ${ sourceDir }`)
512
+ console.log(`${ chalk.bgBlackBright('Target path:') } ${ targetDir }`)
512
513
  console.log()
513
- console.log(`Combining a total of ${processed.total} file(s)`)
514
+ console.log(`Combining a total of ${ processed.total } file(s)`)
514
515
  console.log()
515
516
 
516
517
  const promList = []
@@ -540,7 +541,7 @@ function processCombine(typeItem, argv) {
540
541
  errors++
541
542
  }
542
543
  })
543
- let message = `Combined ${chalk.bgBlackBright(successes)} file(s) ${(errors > 0) ? 'with ' + chalk.bgBlackBright(errors) + 'error(s) ' : ''}in `
544
+ let message = `Combined ${ chalk.bgBlackBright(successes) } file(s) ${ (errors > 0) ? 'with ' + chalk.bgBlackBright(errors) + 'error(s) ' : '' }in `
544
545
  displayMessageAndDuration(startTime, message)
545
546
  resolve(true)
546
547
  })
@@ -561,7 +562,10 @@ function gitFiles(data) {
561
562
  }
562
563
  break
563
564
  case 'delete':
564
- global.metaTypes[getKey(pathArray[3])].remove.files.push(item.path)
565
+ global.metaTypes[getKey(pathArray[3])].remove.files.push(item.path);
566
+ if (!global.metaTypes[getKey(pathArray[3])].remove.directories.includes(pathArray[4])) {
567
+ global.metaTypes[getKey(pathArray[3])].remove.directories.push(pathArray[4]);
568
+ }
565
569
  break
566
570
  }
567
571
  }
@@ -572,4 +576,4 @@ function gitFiles(data) {
572
576
  let data1 = item.path
573
577
  }
574
578
  })
575
- }
579
+ }