@ds-sfdc/sfparty 1.4.0 → 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 CHANGED
@@ -1,9 +1,8 @@
1
1
  {
2
- "semi": false,
3
- "useTabs": true,
4
- "tabWidth": 4,
5
- "singleQuote": true,
6
- "trailingComma": "all",
7
- "printWidth": 80
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ds-sfdc/sfparty",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "Salesforce metadata XML splitter for CI/CD",
5
5
  "type": "module",
6
6
  "repository": {
@@ -33,6 +33,9 @@ export class Combine {
33
33
  }
34
34
  #json = {}
35
35
  #diffOnly = false
36
+ #addedFiles = []
37
+ #deletedFiles = []
38
+ #mainDeleted = false
36
39
 
37
40
  constructor(config) {
38
41
  this.metadataDefinition = config.metadataDefinition
@@ -118,28 +121,50 @@ export class Combine {
118
121
  })
119
122
 
120
123
  function processStart(that) {
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
+
121
151
  let success = processParts(that)
152
+ // Ensure we only match existing metadata type directory and item
153
+
122
154
  if (success) {
123
155
  if (
124
156
  !that.metadataDefinition.packageTypeIsDirectory &&
125
157
  global.git.enabled
126
158
  ) {
127
- if (
128
- !that.#diffOnly ||
129
- global.metaTypes[that.metadataDefinition.alias].add
130
- .files.length > 0
131
- ) {
159
+ if (!that.#diffOnly || that.#addedFiles.length > 0) {
132
160
  that.addPkg.addMember(
133
161
  that.#root,
134
162
  that.#fileName.shortName,
135
163
  )
136
164
  }
137
165
 
138
- if (
139
- that.#diffOnly &&
140
- global.metaTypes[that.metadataDefinition.alias].remove
141
- .files.length > 0
142
- ) {
166
+ // only include the workflow node if main part file is delete
167
+ if (that.#diffOnly && that.#mainDeleted) {
143
168
  that.desPkg.addMember(
144
169
  that.#root,
145
170
  that.#fileName.shortName,
@@ -364,19 +389,21 @@ export class Combine {
364
389
  )
365
390
  }
366
391
 
367
- const diffFiles = global.metaTypes[
368
- that.metadataDefinition.alias
369
- ].add.files.concat(
370
- global.metaTypes[that.metadataDefinition.alias].remove.files,
371
- )
372
-
373
392
  if (that.#diffOnly) {
374
- if (!diffFiles.includes(fileObj.fullName)) return true
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
375
402
  }
376
403
 
377
404
  if (!fileUtils.fileExists({ filePath: fileObj.fullName, fs })) {
378
405
  // File does not exist
379
- // If file is main.yaml, then return false to indicate that the XML file should be deleted
406
+ // If file is main part file, then return false to indicate that the XML file should be deleted
380
407
  if (
381
408
  fileObj.fullName ==
382
409
  path.join(
@@ -389,6 +416,7 @@ export class Combine {
389
416
  }
390
417
 
391
418
  if (
419
+ // git enabled and (package directory OR package mapping)
392
420
  global.git.enabled &&
393
421
  (that.metadataDefinition.packageTypeIsDirectory ||
394
422
  (that.metadataDefinition.package !== undefined &&
@@ -396,6 +424,7 @@ export class Combine {
396
424
  that.metadataDefinition.package))
397
425
  ) {
398
426
  if (
427
+ // package mapping
399
428
  that.metadataDefinition.package !== undefined &&
400
429
  path.dirname(fileObj.fullName).split('/').pop() in
401
430
  that.metadataDefinition.package
@@ -411,7 +440,10 @@ export class Combine {
411
440
  '',
412
441
  ),
413
442
  )
414
- } else if (that.metadataDefinition.packageTypeIsDirectory) {
443
+ } else if (
444
+ // package directory
445
+ that.metadataDefinition.packageTypeIsDirectory
446
+ ) {
415
447
  that.desPkg.addMember(
416
448
  that.#root,
417
449
  fileObj.shortName.replace(`.${global.format}`, ''),