@ds-sfdc/sfparty 1.2.2 → 1.2.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 +1 -1
- package/src/index.js +12 -11
- package/src/lib/fileUtils.js +1 -1
- package/src/lib/gitUtils.js +16 -11
- package/src/party/combine.js +63 -30
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -17,6 +17,7 @@ import * as profileDefinition from './meta/Profiles.js'
|
|
|
17
17
|
import * as permsetDefinition from './meta/PermissionSets.js'
|
|
18
18
|
import * as workflowDefinition from './meta/Workflows.js'
|
|
19
19
|
import * as git from './lib/gitUtils.js'
|
|
20
|
+
import logUpdate from 'log-update'
|
|
20
21
|
|
|
21
22
|
const processStartTime = process.hrtime.bigint()
|
|
22
23
|
|
|
@@ -35,6 +36,7 @@ global.icons = {
|
|
|
35
36
|
"fail": '❗',
|
|
36
37
|
"working": '⏳',
|
|
37
38
|
"party": '🎉',
|
|
39
|
+
"delete": '❌💀❌',
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
global.displayError = (error, quit = false) => {
|
|
@@ -243,8 +245,9 @@ yargs(hideBin(process.argv))
|
|
|
243
245
|
reject(error)
|
|
244
246
|
})
|
|
245
247
|
}
|
|
248
|
+
} else {
|
|
249
|
+
resolve(false)
|
|
246
250
|
}
|
|
247
|
-
|
|
248
251
|
})
|
|
249
252
|
startProm.then((result) => {
|
|
250
253
|
global.git.enabled = result
|
|
@@ -445,6 +448,9 @@ function combineHandler(argv, startTime) {
|
|
|
445
448
|
}
|
|
446
449
|
}
|
|
447
450
|
})
|
|
451
|
+
combine.catch((error) => {
|
|
452
|
+
throw error
|
|
453
|
+
})
|
|
448
454
|
|
|
449
455
|
}
|
|
450
456
|
|
|
@@ -481,7 +487,7 @@ function processCombine(typeItem, argv) {
|
|
|
481
487
|
|
|
482
488
|
|
|
483
489
|
if (type == global.metaTypes.label.type) {
|
|
484
|
-
if (!global.git.enabled || [...new Set([...global.metaTypes.
|
|
490
|
+
if (!global.git.enabled || [...new Set([...global.metaTypes[typeItem].add.directories, ...global.metaTypes[typeItem].remove.directories])].includes(global.metaTypes[typeItem].definition.root)) {
|
|
485
491
|
processList.push(global.metaTypes.label.definition.root)
|
|
486
492
|
}
|
|
487
493
|
} else if (!all) {
|
|
@@ -493,26 +499,25 @@ function processCombine(typeItem, argv) {
|
|
|
493
499
|
processList.push(name)
|
|
494
500
|
} else {
|
|
495
501
|
if (global.git.enabled) {
|
|
496
|
-
processList = [...new Set([...global.metaTypes.
|
|
502
|
+
processList = [...new Set([...global.metaTypes[typeItem].add.directories, ...global.metaTypes[typeItem].remove.directories])]
|
|
497
503
|
} else {
|
|
498
504
|
processList = fileUtils.getDirectories(sourceDir)
|
|
499
505
|
}
|
|
500
506
|
}
|
|
501
507
|
|
|
502
508
|
processed.total = processList.length
|
|
509
|
+
console.log(`${ chalk.bgBlackBright(processed.total) } ${ typeItem } file(s) to process`)
|
|
503
510
|
|
|
504
511
|
// Abort if there are no files to process
|
|
505
512
|
if (processed.total == 0) {
|
|
506
|
-
console.log(`${ chalk.bgBlackBright('0') } ${ typeItem } files to process`)
|
|
507
513
|
resolve(true)
|
|
508
514
|
return
|
|
509
515
|
}
|
|
510
516
|
|
|
517
|
+
console.log()
|
|
511
518
|
console.log(`${ chalk.bgBlackBright('Source path:') } ${ sourceDir }`)
|
|
512
519
|
console.log(`${ chalk.bgBlackBright('Target path:') } ${ targetDir }`)
|
|
513
520
|
console.log()
|
|
514
|
-
console.log(`Combining a total of ${ processed.total } file(s)`)
|
|
515
|
-
console.log()
|
|
516
521
|
|
|
517
522
|
const promList = []
|
|
518
523
|
processList.forEach(metaDir => {
|
|
@@ -533,7 +538,7 @@ function processCombine(typeItem, argv) {
|
|
|
533
538
|
|
|
534
539
|
Promise.allSettled(promList).then((results) => {
|
|
535
540
|
let successes = 0
|
|
536
|
-
let errors =
|
|
541
|
+
let errors = processed.errors++
|
|
537
542
|
results.forEach(result => {
|
|
538
543
|
if (result.value == true) {
|
|
539
544
|
successes++
|
|
@@ -571,9 +576,5 @@ function gitFiles(data) {
|
|
|
571
576
|
}
|
|
572
577
|
}
|
|
573
578
|
}
|
|
574
|
-
const found = typeArray.some(r => item.path.split(path.sep).includes(r))
|
|
575
|
-
if (found.length > 0) {
|
|
576
|
-
let data1 = item.path
|
|
577
|
-
}
|
|
578
579
|
})
|
|
579
580
|
}
|
package/src/lib/fileUtils.js
CHANGED
package/src/lib/gitUtils.js
CHANGED
|
@@ -47,8 +47,11 @@ export function diff(dir, gitRef) {
|
|
|
47
47
|
const gitData = gitString.split(os.EOL)
|
|
48
48
|
let leftOver = ''
|
|
49
49
|
gitData.forEach((gitRow, index) => {
|
|
50
|
-
if (index < count || lastIndex + 1 == gitString) {
|
|
50
|
+
if (gitRow.indexOf('\t') !== -1 &&(index < count || lastIndex + 1 == gitString)) {
|
|
51
51
|
const file = gitRow.split('\t')
|
|
52
|
+
if (file.slice(-1)[0] == 'uthorizationFormConsent.yaml') {
|
|
53
|
+
let test = true
|
|
54
|
+
}
|
|
52
55
|
if (file.slice(-1) !== '') {
|
|
53
56
|
files.push({
|
|
54
57
|
type: status[(file[0] === file.slice(-1)) ? 'A' : Array.from(file[0])[0]],
|
|
@@ -76,16 +79,18 @@ export function diff(dir, gitRef) {
|
|
|
76
79
|
reject(error)
|
|
77
80
|
})
|
|
78
81
|
gitDiff.on("close", code => {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
82
|
+
if (data !== '') {
|
|
83
|
+
const gitData = data.toString().split(os.EOL)
|
|
84
|
+
gitData.forEach(gitRow => {
|
|
85
|
+
const file = gitRow.split('\t')
|
|
86
|
+
if (file.slice(-1) !== '') {
|
|
87
|
+
files.push({
|
|
88
|
+
type: status[(file[0] === file.slice(-1)) ? 'A' : Array.from(file[0])[0]],
|
|
89
|
+
path: file.slice(-1)[0],
|
|
90
|
+
})
|
|
91
|
+
}
|
|
92
|
+
})
|
|
93
|
+
}
|
|
89
94
|
|
|
90
95
|
resolve(files)
|
|
91
96
|
})
|
package/src/party/combine.js
CHANGED
|
@@ -102,9 +102,21 @@ export class Combine {
|
|
|
102
102
|
that.#json[key] = undefined
|
|
103
103
|
})
|
|
104
104
|
|
|
105
|
-
getXML(that)
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
let success = getXML(that)
|
|
106
|
+
if (success) {
|
|
107
|
+
saveXML(that)
|
|
108
|
+
} else {
|
|
109
|
+
logUpdate(that.#spinnerMessage
|
|
110
|
+
.replace('[%1]', that.sequence.toString().padStart(that.total.toString().length, ' '))
|
|
111
|
+
.replace('[%2]', `. ${chalk.redBright('source not found - removing XML file')}`)
|
|
112
|
+
.replace('[%3]', ``)
|
|
113
|
+
.replace('[%4]', `${global.icons.delete} `)
|
|
114
|
+
.replace('[%5]', that.#fileName.shortName)
|
|
115
|
+
)
|
|
116
|
+
logUpdate.done()
|
|
117
|
+
deleteFile(that.#fileName.fullName)
|
|
118
|
+
resolve('deleted')
|
|
119
|
+
}
|
|
108
120
|
resolve(true)
|
|
109
121
|
})
|
|
110
122
|
|
|
@@ -118,35 +130,47 @@ export class Combine {
|
|
|
118
130
|
that.#startTime = process.hrtime.bigint()
|
|
119
131
|
that.#spinnerMessage = `[%1] of ${that.total} - ${that.#root}: [%4]${chalk.yellowBright('[%5]')}[%2][%3]`
|
|
120
132
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
133
|
+
try {
|
|
134
|
+
that.#types.forEach(key => {
|
|
135
|
+
// display message
|
|
136
|
+
logUpdate(that.#spinnerMessage
|
|
137
|
+
.replace('[%1]', that.sequence.toString().padStart(that.total.toString().length, ' '))
|
|
138
|
+
.replace('[%2]', `\n${chalk.magentaBright(nextFrame(that))} ${key}`)
|
|
139
|
+
.replace('[%3]', `${that.#errorMessage}`)
|
|
140
|
+
.replace('[%4]', `${global.icons.working} `)
|
|
141
|
+
.replace('[%5]', `${that.#fileName.shortName} `)
|
|
142
|
+
)
|
|
130
143
|
|
|
131
144
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
145
|
+
if (that.metadataDefinition.main.includes(key)) {
|
|
146
|
+
// TODO process main
|
|
147
|
+
const fileObj = {
|
|
148
|
+
shortName: 'Main',
|
|
149
|
+
fullName: path.join(that.sourceDir, that.metaDir, `main.${global.format}`),
|
|
150
|
+
}
|
|
151
|
+
let success = processFile(that, key, fileObj, 'main')
|
|
152
|
+
if (!success) {
|
|
153
|
+
throw new Error('delete XML')
|
|
154
|
+
}
|
|
155
|
+
if (that.#json.$ === undefined) {
|
|
156
|
+
that.#json.$ = { xmlns: 'https://soap.sforce.com/2006/04/metadata' }
|
|
157
|
+
}
|
|
158
|
+
} else if (that.metadataDefinition.singleFiles.includes(key)) {
|
|
159
|
+
processSingleFile(that, key)
|
|
160
|
+
} else if (that.metadataDefinition.directories.includes(key)) {
|
|
161
|
+
processDirectory(that, key)
|
|
162
|
+
} else {
|
|
163
|
+
global.logger.warn(`Unexpected metadata type: ${chalk.redBright(key)}`)
|
|
141
164
|
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
165
|
+
})
|
|
166
|
+
return true
|
|
167
|
+
} catch (error) {
|
|
168
|
+
if (error.message == 'delete XML') {
|
|
169
|
+
return false
|
|
146
170
|
} else {
|
|
147
|
-
|
|
171
|
+
return true
|
|
148
172
|
}
|
|
149
|
-
}
|
|
173
|
+
}
|
|
150
174
|
}
|
|
151
175
|
|
|
152
176
|
function processSingleFile(that, key) {
|
|
@@ -188,6 +212,10 @@ export class Combine {
|
|
|
188
212
|
return true
|
|
189
213
|
}
|
|
190
214
|
|
|
215
|
+
function deleteFile(fileName) {
|
|
216
|
+
fileUtils.deleteFile(fileName)
|
|
217
|
+
}
|
|
218
|
+
|
|
191
219
|
function processFile(that, key, fileObj = undefined, rootKey = undefined) {
|
|
192
220
|
if (
|
|
193
221
|
fileObj === undefined ||
|
|
@@ -200,7 +228,12 @@ export class Combine {
|
|
|
200
228
|
}
|
|
201
229
|
|
|
202
230
|
if (!fileUtils.fileExists(fileObj.fullName)) {
|
|
203
|
-
|
|
231
|
+
// File does not exist
|
|
232
|
+
// If file is main.yaml, then return false to indicate that the XML file should be deleted
|
|
233
|
+
if (fileObj.fullName == path.join(that.sourceDir, that.metaDir, `main.${global.format}`)) {
|
|
234
|
+
return false
|
|
235
|
+
}
|
|
236
|
+
return true
|
|
204
237
|
}
|
|
205
238
|
|
|
206
239
|
let result = fileUtils.readFile(fileObj.fullName)
|
|
@@ -216,7 +249,7 @@ export class Combine {
|
|
|
216
249
|
if (Array.isArray(result[key])) {
|
|
217
250
|
result[key].forEach(arrItem => {
|
|
218
251
|
that.#json[key].push(arrItem)
|
|
219
|
-
})
|
|
252
|
+
})
|
|
220
253
|
} else {
|
|
221
254
|
that.#json[key].push(result[key])
|
|
222
255
|
}
|
|
@@ -233,7 +266,7 @@ export class Combine {
|
|
|
233
266
|
}
|
|
234
267
|
|
|
235
268
|
updateFileStats(that, fileObj.fullName, fileUtils.fileInfo(fileObj.fullName).stats)
|
|
236
|
-
|
|
269
|
+
return true
|
|
237
270
|
}
|
|
238
271
|
|
|
239
272
|
function hydrateObject(that, json, key, fileObj) {
|