@ds-sfdc/sfparty 1.2.1 → 1.2.3
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
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
|
|
@@ -243,7 +244,7 @@ yargs(hideBin(process.argv))
|
|
|
243
244
|
})
|
|
244
245
|
}
|
|
245
246
|
}
|
|
246
|
-
|
|
247
|
+
resolve(false)
|
|
247
248
|
})
|
|
248
249
|
startProm.then((result) => {
|
|
249
250
|
global.git.enabled = result
|
|
@@ -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
|
})
|
|
@@ -444,6 +445,9 @@ function combineHandler(argv, startTime) {
|
|
|
444
445
|
}
|
|
445
446
|
}
|
|
446
447
|
})
|
|
448
|
+
combine.catch((error) => {
|
|
449
|
+
throw error
|
|
450
|
+
})
|
|
447
451
|
|
|
448
452
|
}
|
|
449
453
|
|
|
@@ -477,10 +481,10 @@ function processCombine(typeItem, argv) {
|
|
|
477
481
|
targetDir = path.join(targetDir, 'main', 'default', typeObj.definition.directory)
|
|
478
482
|
}
|
|
479
483
|
|
|
480
|
-
|
|
484
|
+
|
|
481
485
|
|
|
482
486
|
if (type == global.metaTypes.label.type) {
|
|
483
|
-
if (!global.git.enabled || global.metaTypes.label.add.directories.includes(global.metaTypes.label.definition.root)) {
|
|
487
|
+
if (!global.git.enabled || [...new Set([...global.metaTypes.label.add.directories, ...global.metaTypes.label.remove.directories])].includes(global.metaTypes.label.definition.root)) {
|
|
484
488
|
processList.push(global.metaTypes.label.definition.root)
|
|
485
489
|
}
|
|
486
490
|
} else if (!all) {
|
|
@@ -492,7 +496,7 @@ function processCombine(typeItem, argv) {
|
|
|
492
496
|
processList.push(name)
|
|
493
497
|
} else {
|
|
494
498
|
if (global.git.enabled) {
|
|
495
|
-
processList = global.metaTypes
|
|
499
|
+
processList = [...new Set([...global.metaTypes.label.add.directories, ...global.metaTypes.label.remove.directories])]
|
|
496
500
|
} else {
|
|
497
501
|
processList = fileUtils.getDirectories(sourceDir)
|
|
498
502
|
}
|
|
@@ -502,15 +506,15 @@ function processCombine(typeItem, argv) {
|
|
|
502
506
|
|
|
503
507
|
// Abort if there are no files to process
|
|
504
508
|
if (processed.total == 0) {
|
|
505
|
-
console.log(`${chalk.bgBlackBright('0')} ${typeItem} files to process`)
|
|
509
|
+
console.log(`${ chalk.bgBlackBright('0') } ${ typeItem } files to process`)
|
|
506
510
|
resolve(true)
|
|
507
511
|
return
|
|
508
512
|
}
|
|
509
513
|
|
|
510
|
-
console.log(`${chalk.bgBlackBright('Source path:')} ${sourceDir}`)
|
|
511
|
-
console.log(`${chalk.bgBlackBright('Target path:')} ${targetDir}`)
|
|
514
|
+
console.log(`${ chalk.bgBlackBright('Source path:') } ${ sourceDir }`)
|
|
515
|
+
console.log(`${ chalk.bgBlackBright('Target path:') } ${ targetDir }`)
|
|
512
516
|
console.log()
|
|
513
|
-
console.log(`Combining a total of ${processed.total} file(s)`)
|
|
517
|
+
console.log(`Combining a total of ${ processed.total } file(s)`)
|
|
514
518
|
console.log()
|
|
515
519
|
|
|
516
520
|
const promList = []
|
|
@@ -540,7 +544,7 @@ function processCombine(typeItem, argv) {
|
|
|
540
544
|
errors++
|
|
541
545
|
}
|
|
542
546
|
})
|
|
543
|
-
let message = `Combined ${chalk.bgBlackBright(successes)} file(s) ${(errors > 0) ? 'with ' + chalk.bgBlackBright(errors) + 'error(s) ' : ''}in `
|
|
547
|
+
let message = `Combined ${ chalk.bgBlackBright(successes) } file(s) ${ (errors > 0) ? 'with ' + chalk.bgBlackBright(errors) + 'error(s) ' : '' }in `
|
|
544
548
|
displayMessageAndDuration(startTime, message)
|
|
545
549
|
resolve(true)
|
|
546
550
|
})
|
|
@@ -561,7 +565,10 @@ function gitFiles(data) {
|
|
|
561
565
|
}
|
|
562
566
|
break
|
|
563
567
|
case 'delete':
|
|
564
|
-
global.metaTypes[getKey(pathArray[3])].remove.files.push(item.path)
|
|
568
|
+
global.metaTypes[getKey(pathArray[3])].remove.files.push(item.path);
|
|
569
|
+
if (!global.metaTypes[getKey(pathArray[3])].remove.directories.includes(pathArray[4])) {
|
|
570
|
+
global.metaTypes[getKey(pathArray[3])].remove.directories.push(pathArray[4]);
|
|
571
|
+
}
|
|
565
572
|
break
|
|
566
573
|
}
|
|
567
574
|
}
|
|
@@ -572,4 +579,4 @@ function gitFiles(data) {
|
|
|
572
579
|
let data1 = item.path
|
|
573
580
|
}
|
|
574
581
|
})
|
|
575
|
-
}
|
|
582
|
+
}
|