@ds-sfdc/sfparty 1.3.16 → 1.4.1
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/.prettierrc +7 -8
- package/package.json +1 -1
- package/src/index.js +39 -9
- package/src/party/combine.js +101 -44
package/.prettierrc
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
"semi": false,
|
|
3
|
+
"useTabs": true,
|
|
4
|
+
"tabWidth": 4,
|
|
5
|
+
"singleQuote": true,
|
|
6
|
+
"trailingComma": "all",
|
|
7
|
+
"printWidth": 80
|
|
8
|
+
}
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { spawnSync, spawn, execSync } from 'child_process'
|
|
|
4
4
|
import fs from 'fs'
|
|
5
5
|
import path from 'path'
|
|
6
6
|
import yargs from 'yargs'
|
|
7
|
+
import xml2js from 'xml2js'
|
|
7
8
|
import { hideBin } from 'yargs/helpers'
|
|
8
9
|
import winston from 'winston'
|
|
9
10
|
import clc from 'cli-color'
|
|
@@ -22,6 +23,7 @@ import * as permsetDefinition from './meta/PermissionSets.js'
|
|
|
22
23
|
import * as workflowDefinition from './meta/Workflows.js'
|
|
23
24
|
import { checkVersion } from './lib/checkVersion.js'
|
|
24
25
|
import * as git from './lib/gitUtils.js'
|
|
26
|
+
import * as packageUtil from './lib/packageUtil.js'
|
|
25
27
|
|
|
26
28
|
const processStartTime = process.hrtime.bigint()
|
|
27
29
|
|
|
@@ -109,7 +111,8 @@ let errorMessage = clc.red(
|
|
|
109
111
|
clc.whiteBright.bgRedBright('combine') +
|
|
110
112
|
'.',
|
|
111
113
|
)
|
|
112
|
-
|
|
114
|
+
let addPkg
|
|
115
|
+
let desPkg
|
|
113
116
|
displayHeader() // display header mast
|
|
114
117
|
|
|
115
118
|
let checkYargs = false
|
|
@@ -254,7 +257,32 @@ yargs(hideBin(process.argv))
|
|
|
254
257
|
})
|
|
255
258
|
startProm.then((result) => {
|
|
256
259
|
global.git.enabled = result
|
|
257
|
-
|
|
260
|
+
|
|
261
|
+
if (global.git.enabled) {
|
|
262
|
+
let addManifest =
|
|
263
|
+
argv.package || 'manifest/package-party.xml'
|
|
264
|
+
let desManifest =
|
|
265
|
+
argv.destructive ||
|
|
266
|
+
'manifest/destructiveChanges-party.xml'
|
|
267
|
+
|
|
268
|
+
addPkg = new packageUtil.Package(addManifest)
|
|
269
|
+
desPkg = new packageUtil.Package(desManifest)
|
|
270
|
+
const prom1 = addPkg.getPackageXML(fileUtils)
|
|
271
|
+
const prom2 = desPkg.getPackageXML(fileUtils)
|
|
272
|
+
|
|
273
|
+
Promise.allSettled([prom1, prom2]).then((results) => {
|
|
274
|
+
const rejected = results.filter(
|
|
275
|
+
(p) => p.status === 'rejected',
|
|
276
|
+
)
|
|
277
|
+
if (rejected.length > 0) {
|
|
278
|
+
throw new Error(rejected[0].value)
|
|
279
|
+
} else {
|
|
280
|
+
combineHandler(argv, processStartTime)
|
|
281
|
+
}
|
|
282
|
+
})
|
|
283
|
+
} else {
|
|
284
|
+
combineHandler(argv, processStartTime)
|
|
285
|
+
}
|
|
258
286
|
})
|
|
259
287
|
startProm.catch((error) => {
|
|
260
288
|
global.displayError(error, true)
|
|
@@ -565,6 +593,10 @@ function combineHandler(argv, startTime) {
|
|
|
565
593
|
fs,
|
|
566
594
|
})
|
|
567
595
|
}
|
|
596
|
+
if (global.git.enabled) {
|
|
597
|
+
addPkg.savePackage(xml2js, fileUtils)
|
|
598
|
+
desPkg.savePackage(xml2js, fileUtils)
|
|
599
|
+
}
|
|
568
600
|
if (argv.type === undefined || argv.type.split(',').length > 1) {
|
|
569
601
|
let message = `Split completed in `
|
|
570
602
|
displayMessageAndDuration(startTime, message)
|
|
@@ -599,8 +631,6 @@ function processCombine(typeItem, argv) {
|
|
|
599
631
|
let name = argv.name
|
|
600
632
|
let all =
|
|
601
633
|
argv.type === undefined || name === undefined ? true : argv.all
|
|
602
|
-
let addManifest = argv.package
|
|
603
|
-
let desManifest = argv.destructive
|
|
604
634
|
|
|
605
635
|
sourceDir = path.join(
|
|
606
636
|
global.__basedir,
|
|
@@ -680,13 +710,13 @@ function processCombine(typeItem, argv) {
|
|
|
680
710
|
processList.forEach((metaDir) => {
|
|
681
711
|
const metadataItem = new metadataCombine.Combine({
|
|
682
712
|
metadataDefinition: typeObj.definition,
|
|
683
|
-
sourceDir
|
|
684
|
-
targetDir
|
|
685
|
-
metaDir
|
|
713
|
+
sourceDir,
|
|
714
|
+
targetDir,
|
|
715
|
+
metaDir,
|
|
686
716
|
sequence: promList.length + 1,
|
|
687
717
|
total: processed.total,
|
|
688
|
-
|
|
689
|
-
|
|
718
|
+
addPkg,
|
|
719
|
+
desPkg,
|
|
690
720
|
})
|
|
691
721
|
const metadataItemProm = metadataItem.combine()
|
|
692
722
|
promList.push(metadataItemProm)
|
package/src/party/combine.js
CHANGED
|
@@ -15,7 +15,6 @@ const processed = {
|
|
|
15
15
|
current: 0,
|
|
16
16
|
type: undefined,
|
|
17
17
|
}
|
|
18
|
-
|
|
19
18
|
export class Combine {
|
|
20
19
|
#type = undefined
|
|
21
20
|
#root = undefined
|
|
@@ -33,8 +32,10 @@ export class Combine {
|
|
|
33
32
|
mtime: undefined,
|
|
34
33
|
}
|
|
35
34
|
#json = {}
|
|
36
|
-
#
|
|
37
|
-
#
|
|
35
|
+
#diffOnly = false
|
|
36
|
+
#addedFiles = []
|
|
37
|
+
#deletedFiles = []
|
|
38
|
+
#mainDeleted = false
|
|
38
39
|
|
|
39
40
|
constructor(config) {
|
|
40
41
|
this.metadataDefinition = config.metadataDefinition
|
|
@@ -43,9 +44,8 @@ export class Combine {
|
|
|
43
44
|
this.metaDir = config.metaDir
|
|
44
45
|
this.sequence = config.sequence
|
|
45
46
|
this.total = config.total
|
|
46
|
-
this.
|
|
47
|
-
this.
|
|
48
|
-
config.desManifest || 'manifest/destructiveChanges-party.xml'
|
|
47
|
+
this.addPkg = config.addPkg
|
|
48
|
+
this.desPkg = config.desPkg
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
get metadataDefinition() {
|
|
@@ -86,6 +86,12 @@ export class Combine {
|
|
|
86
86
|
combine() {
|
|
87
87
|
return new Promise((resolve, reject) => {
|
|
88
88
|
const that = this
|
|
89
|
+
that.#diffOnly =
|
|
90
|
+
global.metaTypes[that.metadataDefinition.alias].add.files
|
|
91
|
+
.length > 0 ||
|
|
92
|
+
global.metaTypes[that.metadataDefinition.alias].remove.files
|
|
93
|
+
.length > 0
|
|
94
|
+
|
|
89
95
|
if (!fileUtils.directoryExists({ dirPath: that.sourceDir, fs }))
|
|
90
96
|
reject(`Path does not exist: ${that.sourceDir}`)
|
|
91
97
|
let types = ['directories', 'singleFiles', 'main']
|
|
@@ -111,38 +117,61 @@ export class Combine {
|
|
|
111
117
|
that.#json[key] = undefined
|
|
112
118
|
})
|
|
113
119
|
|
|
114
|
-
|
|
115
|
-
that.#addPkg = new packageUtil.Package(that.addManifest)
|
|
116
|
-
that.#desPkg = new packageUtil.Package(that.desManifest)
|
|
117
|
-
const prom1 = that.#addPkg.getPackageXML(fileUtils)
|
|
118
|
-
const prom2 = that.#desPkg.getPackageXML(fileUtils)
|
|
119
|
-
|
|
120
|
-
Promise.allSettled([prom1, prom2]).then((results) => {
|
|
121
|
-
const rejected = results.filter(
|
|
122
|
-
(p) => p.status === 'rejected',
|
|
123
|
-
)
|
|
124
|
-
if (rejected.length > 0) {
|
|
125
|
-
reject(rejected[0].value)
|
|
126
|
-
} else {
|
|
127
|
-
resolve(processStart(that))
|
|
128
|
-
}
|
|
129
|
-
})
|
|
130
|
-
} else {
|
|
131
|
-
resolve(processStart(that))
|
|
132
|
-
}
|
|
120
|
+
resolve(processStart(that))
|
|
133
121
|
})
|
|
134
122
|
|
|
135
123
|
function processStart(that) {
|
|
136
|
-
|
|
124
|
+
const pathMatch = `/${that.metadataDefinition.directory}/${
|
|
125
|
+
that.#fileName.shortName
|
|
126
|
+
}/`
|
|
127
|
+
|
|
128
|
+
// get a list of all the added files
|
|
129
|
+
that.#addedFiles = global.metaTypes[
|
|
130
|
+
that.metadataDefinition.alias
|
|
131
|
+
].add.files.filter((i) =>
|
|
132
|
+
i.toLowerCase().includes(pathMatch.toLowerCase()),
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
// get a list of all the removed files
|
|
136
|
+
that.#deletedFiles = global.metaTypes[
|
|
137
|
+
that.metadataDefinition.alias
|
|
138
|
+
].remove.files.filter((i) =>
|
|
139
|
+
i.toLowerCase().includes(pathMatch.toLowerCase()),
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
// check if main part file deleted
|
|
143
|
+
that.#mainDeleted = global.metaTypes[
|
|
144
|
+
that.metadataDefinition.alias
|
|
145
|
+
].remove.files.some(
|
|
146
|
+
(i) =>
|
|
147
|
+
i.includes(pathMatch) &&
|
|
148
|
+
i.toLowerCase().includes(`/main.${global.format}`),
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
let success = processParts(that)
|
|
152
|
+
// Ensure we only match existing metadata type directory and item
|
|
153
|
+
|
|
137
154
|
if (success) {
|
|
138
155
|
if (
|
|
139
156
|
!that.metadataDefinition.packageTypeIsDirectory &&
|
|
140
157
|
global.git.enabled
|
|
141
158
|
) {
|
|
142
|
-
|
|
159
|
+
if (!that.#diffOnly || that.#addedFiles.length > 0) {
|
|
160
|
+
that.addPkg.addMember(
|
|
161
|
+
that.#root,
|
|
162
|
+
that.#fileName.shortName,
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// only include the workflow node if main part file is delete
|
|
167
|
+
if (that.#diffOnly && that.#mainDeleted) {
|
|
168
|
+
that.desPkg.addMember(
|
|
169
|
+
that.#root,
|
|
170
|
+
that.#fileName.shortName,
|
|
171
|
+
)
|
|
172
|
+
}
|
|
143
173
|
}
|
|
144
174
|
saveXML(that)
|
|
145
|
-
if (global.git.enabled) savePackageXML(that)
|
|
146
175
|
return true
|
|
147
176
|
} else {
|
|
148
177
|
logUpdate(
|
|
@@ -168,20 +197,14 @@ export class Combine {
|
|
|
168
197
|
!that.metadataDefinition.packageTypeIsDirectory &&
|
|
169
198
|
global.git.enabled
|
|
170
199
|
) {
|
|
171
|
-
that
|
|
200
|
+
that.desPkg.addMember(that.#root, that.#fileName.shortName)
|
|
172
201
|
}
|
|
173
|
-
deleteFile(that.#fileName.fullName)
|
|
174
|
-
if (global.git.enabled) savePackageXML(that)
|
|
202
|
+
deleteFile(that, that.#fileName.fullName)
|
|
175
203
|
return 'deleted'
|
|
176
204
|
}
|
|
177
205
|
}
|
|
178
206
|
|
|
179
|
-
function
|
|
180
|
-
that.#addPkg.savePackage(xml2js, fileUtils)
|
|
181
|
-
that.#desPkg.savePackage(xml2js, fileUtils)
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
function getXML(that) {
|
|
207
|
+
function processParts(that) {
|
|
185
208
|
if (processed.type != that.#root) {
|
|
186
209
|
processed.current = 0
|
|
187
210
|
processed.type = that.#root
|
|
@@ -320,11 +343,28 @@ export class Combine {
|
|
|
320
343
|
processFile(that, key, fileObj)
|
|
321
344
|
})
|
|
322
345
|
}
|
|
346
|
+
|
|
347
|
+
const filteredArray = global.metaTypes[
|
|
348
|
+
that.metadataDefinition.alias
|
|
349
|
+
].remove.files.filter((filePath) =>
|
|
350
|
+
filePath.startsWith(
|
|
351
|
+
path.join(that.sourceDir, that.metaDir, key),
|
|
352
|
+
),
|
|
353
|
+
)
|
|
354
|
+
filteredArray.forEach((file) => {
|
|
355
|
+
const fileObj = {
|
|
356
|
+
shortName: path.basename(file),
|
|
357
|
+
fullName: file,
|
|
358
|
+
}
|
|
359
|
+
processFile(that, key, fileObj)
|
|
360
|
+
})
|
|
361
|
+
|
|
323
362
|
return true
|
|
324
363
|
}
|
|
325
364
|
|
|
326
|
-
function deleteFile(fileName) {
|
|
365
|
+
function deleteFile(that, fileName) {
|
|
327
366
|
fileUtils.deleteFile(fileName)
|
|
367
|
+
fileUtils.deleteDirectory(path.join(that.sourceDir, that.metaDir))
|
|
328
368
|
}
|
|
329
369
|
|
|
330
370
|
function processFile(
|
|
@@ -349,9 +389,21 @@ export class Combine {
|
|
|
349
389
|
)
|
|
350
390
|
}
|
|
351
391
|
|
|
392
|
+
if (that.#diffOnly) {
|
|
393
|
+
if (
|
|
394
|
+
!that.#addedFiles
|
|
395
|
+
.concat(that.#deletedFiles)
|
|
396
|
+
.includes(fileObj.fullName) &&
|
|
397
|
+
!fileObj.fullName
|
|
398
|
+
.toLowerCase()
|
|
399
|
+
.includes(`/main.${global.format}`)
|
|
400
|
+
)
|
|
401
|
+
return true
|
|
402
|
+
}
|
|
403
|
+
|
|
352
404
|
if (!fileUtils.fileExists({ filePath: fileObj.fullName, fs })) {
|
|
353
405
|
// File does not exist
|
|
354
|
-
// If file is main
|
|
406
|
+
// If file is main part file, then return false to indicate that the XML file should be deleted
|
|
355
407
|
if (
|
|
356
408
|
fileObj.fullName ==
|
|
357
409
|
path.join(
|
|
@@ -364,6 +416,7 @@ export class Combine {
|
|
|
364
416
|
}
|
|
365
417
|
|
|
366
418
|
if (
|
|
419
|
+
// git enabled and (package directory OR package mapping)
|
|
367
420
|
global.git.enabled &&
|
|
368
421
|
(that.metadataDefinition.packageTypeIsDirectory ||
|
|
369
422
|
(that.metadataDefinition.package !== undefined &&
|
|
@@ -371,11 +424,12 @@ export class Combine {
|
|
|
371
424
|
that.metadataDefinition.package))
|
|
372
425
|
) {
|
|
373
426
|
if (
|
|
427
|
+
// package mapping
|
|
374
428
|
that.metadataDefinition.package !== undefined &&
|
|
375
429
|
path.dirname(fileObj.fullName).split('/').pop() in
|
|
376
430
|
that.metadataDefinition.package
|
|
377
431
|
) {
|
|
378
|
-
that
|
|
432
|
+
that.desPkg.addMember(
|
|
379
433
|
that.metadataDefinition.package[
|
|
380
434
|
path.dirname(fileObj.fullName).split('/').pop()
|
|
381
435
|
],
|
|
@@ -386,8 +440,11 @@ export class Combine {
|
|
|
386
440
|
'',
|
|
387
441
|
),
|
|
388
442
|
)
|
|
389
|
-
} else if (
|
|
390
|
-
|
|
443
|
+
} else if (
|
|
444
|
+
// package directory
|
|
445
|
+
that.metadataDefinition.packageTypeIsDirectory
|
|
446
|
+
) {
|
|
447
|
+
that.desPkg.addMember(
|
|
391
448
|
that.#root,
|
|
392
449
|
fileObj.shortName.replace(`.${global.format}`, ''),
|
|
393
450
|
)
|
|
@@ -459,7 +516,7 @@ export class Combine {
|
|
|
459
516
|
path.dirname(fileObj.fullName).split('/').pop() in
|
|
460
517
|
that.metadataDefinition.package
|
|
461
518
|
) {
|
|
462
|
-
that
|
|
519
|
+
that.addPkg.addMember(
|
|
463
520
|
that.metadataDefinition.package[
|
|
464
521
|
path.dirname(fileObj.fullName).split('/').pop()
|
|
465
522
|
],
|
|
@@ -468,7 +525,7 @@ export class Combine {
|
|
|
468
525
|
fileObj.shortName.replace(`.${global.format}`, ''),
|
|
469
526
|
)
|
|
470
527
|
} else if (that.metadataDefinition.packageTypeIsDirectory) {
|
|
471
|
-
that
|
|
528
|
+
that.addPkg.addMember(
|
|
472
529
|
that.#root,
|
|
473
530
|
fileObj.shortName.replace(`.${global.format}`, ''),
|
|
474
531
|
)
|