@ds-sfdc/sfparty 1.2.0 → 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.0",
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
 
@@ -280,7 +281,6 @@ function yargCheck(argv, options) {
280
281
  if ((typeof name != 'undefined' && name != '')) {
281
282
  throw new Error(chalk.redBright('You cannot specify ' + chalk.whiteBright.bgRedBright('--name') + ' when using multiple types.'))
282
283
  }
283
- return true
284
284
  } else {
285
285
  switch (argv.type) {
286
286
  case 'label':
@@ -288,36 +288,35 @@ function yargCheck(argv, options) {
288
288
  throw new Error(chalk.redBright('You cannot specify ' + chalk.whiteBright.bgRedBright('--name') + ' when using label.'))
289
289
  }
290
290
  break
291
- default:
292
- return true
293
291
  }
294
292
  }
293
+ return true
295
294
  }
296
295
 
297
296
  function displayMessageAndDuration(startTime, message) {
298
297
  const diff = process.hrtime.bigint() - BigInt(startTime)
299
298
  let durationMessage
300
- let executionTime = convertHrtime(diff);
299
+ let executionTime = convertHrtime(diff)
301
300
  let minutes = Math.floor((executionTime.seconds + Math.round(executionTime.milliseconds / 100000)) / 60)
302
301
  let seconds = Math.round((executionTime.seconds + Math.round(executionTime.milliseconds / 100000)) % 60)
303
302
  if (minutes == 0 && seconds == 0) {
304
303
  durationMessage = message + chalk.magentaBright(`<1s`)
305
304
  } else if (minutes > 0) {
306
- durationMessage = message + chalk.magentaBright(`${minutes}m ${seconds}s`)
305
+ durationMessage = message + chalk.magentaBright(`${ minutes }m ${ seconds }s`)
307
306
  } else {
308
- durationMessage = message + chalk.magentaBright(`${seconds}s`)
307
+ durationMessage = message + chalk.magentaBright(`${ seconds }s`)
309
308
  }
310
309
  console.log('\n' + durationMessage)
311
310
  }
312
311
 
313
- let callAmount = 0;
312
+ let callAmount = 0
314
313
  process.on('SIGINT', function () {
315
314
  if (callAmount < 1) {
316
- console.log(`✅ Received abort command`);
315
+ console.log(`✅ Received abort command`)
317
316
  process.exit(1)
318
317
  }
319
318
 
320
- callAmount++;
319
+ callAmount++
321
320
  })
322
321
 
323
322
  function splitHandler(argv, startTime) {
@@ -353,7 +352,7 @@ function processSplit(typeItem, argv) {
353
352
  const fileList = []
354
353
  const typeObj = global.metaTypes[typeItem]
355
354
  const type = typeObj.type
356
- const metaExtension = `.${type}-meta.xml`
355
+ const metaExtension = `.${ type }-meta.xml`
357
356
 
358
357
  let sourceDir = argv.source || ''
359
358
  let targetDir = argv.target || ''
@@ -393,11 +392,11 @@ function processSplit(typeItem, argv) {
393
392
  processed.total = fileList.length
394
393
 
395
394
  if (processed.total == 0) resolve(true)
396
-
397
- console.log(`${chalk.bgBlackBright('Source path:')} ${sourceDir}`)
398
- console.log(`${chalk.bgBlackBright('Target path:')} ${targetDir}`)
395
+
396
+ console.log(`${ chalk.bgBlackBright('Source path:') } ${ sourceDir }`)
397
+ console.log(`${ chalk.bgBlackBright('Target path:') } ${ targetDir }`)
399
398
  console.log()
400
- console.log(`Splitting a total of ${processed.total} file(s)`)
399
+ console.log(`Splitting a total of ${ processed.total } file(s)`)
401
400
  console.log()
402
401
 
403
402
  const promList = []
@@ -422,7 +421,7 @@ function processSplit(typeItem, argv) {
422
421
  })
423
422
  })
424
423
  Promise.allSettled(promList).then((results) => {
425
- 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 `
426
425
  displayMessageAndDuration(startTime, message)
427
426
  resolve(true)
428
427
  })
@@ -479,10 +478,10 @@ function processCombine(typeItem, argv) {
479
478
  targetDir = path.join(targetDir, 'main', 'default', typeObj.definition.directory)
480
479
  }
481
480
 
482
-
481
+
483
482
 
484
483
  if (type == global.metaTypes.label.type) {
485
- 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)) {
486
485
  processList.push(global.metaTypes.label.definition.root)
487
486
  }
488
487
  } else if (!all) {
@@ -494,7 +493,7 @@ function processCombine(typeItem, argv) {
494
493
  processList.push(name)
495
494
  } else {
496
495
  if (global.git.enabled) {
497
- processList = global.metaTypes[typeItem].add.directories
496
+ processList = [...new Set([...global.metaTypes.label.add.directories, ...global.metaTypes.label.remove.directories])]
498
497
  } else {
499
498
  processList = fileUtils.getDirectories(sourceDir)
500
499
  }
@@ -504,15 +503,15 @@ function processCombine(typeItem, argv) {
504
503
 
505
504
  // Abort if there are no files to process
506
505
  if (processed.total == 0) {
507
- console.log(`${chalk.bgBlackBright('0')} ${typeItem} files to process`)
506
+ console.log(`${ chalk.bgBlackBright('0') } ${ typeItem } files to process`)
508
507
  resolve(true)
509
508
  return
510
509
  }
511
510
 
512
- console.log(`${chalk.bgBlackBright('Source path:')} ${sourceDir}`)
513
- console.log(`${chalk.bgBlackBright('Target path:')} ${targetDir}`)
511
+ console.log(`${ chalk.bgBlackBright('Source path:') } ${ sourceDir }`)
512
+ console.log(`${ chalk.bgBlackBright('Target path:') } ${ targetDir }`)
514
513
  console.log()
515
- console.log(`Combining a total of ${processed.total} file(s)`)
514
+ console.log(`Combining a total of ${ processed.total } file(s)`)
516
515
  console.log()
517
516
 
518
517
  const promList = []
@@ -542,7 +541,7 @@ function processCombine(typeItem, argv) {
542
541
  errors++
543
542
  }
544
543
  })
545
- 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 `
546
545
  displayMessageAndDuration(startTime, message)
547
546
  resolve(true)
548
547
  })
@@ -563,7 +562,10 @@ function gitFiles(data) {
563
562
  }
564
563
  break
565
564
  case 'delete':
566
- 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
+ }
567
569
  break
568
570
  }
569
571
  }
@@ -574,4 +576,4 @@ function gitFiles(data) {
574
576
  let data1 = item.path
575
577
  }
576
578
  })
577
- }
579
+ }