@ds-sfdc/sfparty 1.4.1 → 1.4.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ds-sfdc/sfparty",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "description": "Salesforce metadata XML splitter for CI/CD",
5
5
  "type": "module",
6
6
  "repository": {
@@ -68,8 +68,9 @@ export class Package {
68
68
  packageDefinition.metadataDefinition.fallbackVersion
69
69
  }
70
70
  that.packageJSON = json
71
- if (json.Package.types !== undefined)
71
+ if (json.Package.types !== undefined) {
72
72
  transformJSON(json.Package.types)
73
+ }
73
74
  cleanPackage(that)
74
75
  }
75
76
 
@@ -80,6 +81,7 @@ export class Package {
80
81
  )
81
82
  if (that.packageJSON.Package == undefined)
82
83
  throw new Error('Package initialization failed')
84
+
83
85
  if (that.packageJSON.Package.types === undefined)
84
86
  return 'No types found'
85
87
 
@@ -93,6 +95,12 @@ export class Package {
93
95
  )
94
96
  }
95
97
  })
98
+
99
+ // remove all types nodes that have no members
100
+ that.packageJSON.Package.types =
101
+ that.packageJSON.Package.types.filter(
102
+ (subType) => subType.members.length > 0,
103
+ )
96
104
  }
97
105
  }
98
106
 
@@ -4,6 +4,7 @@ export const metadataDefinition = {
4
4
  directory: 'labels',
5
5
  filetype: 'labels',
6
6
  root: 'CustomLabels',
7
+ type: 'CustomLabel',
7
8
  alias: 'label',
8
9
  main: ['$'],
9
10
  singleFiles: [],
@@ -4,6 +4,7 @@ export const metadataDefinition = {
4
4
  directory: 'permissionsets',
5
5
  filetype: 'permissionset',
6
6
  root: 'PermissionSet',
7
+ type: 'PermissionSet',
7
8
  alias: 'permset',
8
9
  main: [
9
10
  'label',
@@ -74,4 +75,5 @@ export const metadataDefinition = {
74
75
  tabSettings: ['tab', 'visibility'],
75
76
  userPermissions: ['name', 'enabled'],
76
77
  },
78
+ delta: false,
77
79
  }
@@ -4,6 +4,7 @@ export const metadataDefinition = {
4
4
  directory: 'profiles',
5
5
  filetype: 'profile',
6
6
  root: 'Profile',
7
+ type: 'Profile',
7
8
  alias: 'profile',
8
9
  main: ['fullName', 'custom', 'description', 'userLicense', '$'],
9
10
  singleFiles: [
@@ -83,4 +84,5 @@ export const metadataDefinition = {
83
84
  userPermissions: ['name', 'enabled'],
84
85
  },
85
86
  xmlFirst: 'fullName',
87
+ delta: false,
86
88
  }
@@ -4,6 +4,7 @@ export const metadataDefinition = {
4
4
  directory: 'workflows',
5
5
  filetype: 'workflow',
6
6
  root: 'Workflow',
7
+ type: 'Workflow',
7
8
  alias: 'workflow',
8
9
  main: ['$'],
9
10
  singleFiles: [],
@@ -124,4 +125,5 @@ export const metadataDefinition = {
124
125
  rules: 'WorkflowRule',
125
126
  tasks: 'WorkflowTask',
126
127
  },
128
+ delta: true,
127
129
  }
@@ -6,7 +6,6 @@ import cliSpinners from 'cli-spinners'
6
6
  import fs from 'fs'
7
7
  import * as xml2js from 'xml2js'
8
8
  import * as fileUtils from '../lib/fileUtils.js'
9
- import * as packageUtil from '../lib/packageUtil.js'
10
9
 
11
10
  const spinner = cliSpinners['dots']
12
11
  const processed = {
@@ -32,7 +31,7 @@ export class Combine {
32
31
  mtime: undefined,
33
32
  }
34
33
  #json = {}
35
- #diffOnly = false
34
+ #delta = false
36
35
  #addedFiles = []
37
36
  #deletedFiles = []
38
37
  #mainDeleted = false
@@ -86,11 +85,6 @@ export class Combine {
86
85
  combine() {
87
86
  return new Promise((resolve, reject) => {
88
87
  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
88
 
95
89
  if (!fileUtils.directoryExists({ dirPath: that.sourceDir, fs }))
96
90
  reject(`Path does not exist: ${that.sourceDir}`)
@@ -148,6 +142,9 @@ export class Combine {
148
142
  i.toLowerCase().includes(`/main.${global.format}`),
149
143
  )
150
144
 
145
+ // set delta based on metadata definition
146
+ that.#delta = that.metadataDefinition.delta
147
+
151
148
  let success = processParts(that)
152
149
  // Ensure we only match existing metadata type directory and item
153
150
 
@@ -156,17 +153,17 @@ export class Combine {
156
153
  !that.metadataDefinition.packageTypeIsDirectory &&
157
154
  global.git.enabled
158
155
  ) {
159
- if (!that.#diffOnly || that.#addedFiles.length > 0) {
156
+ if (!that.#delta || that.#addedFiles.length > 0) {
160
157
  that.addPkg.addMember(
161
- that.#root,
158
+ that.metadataDefinition.type,
162
159
  that.#fileName.shortName,
163
160
  )
164
161
  }
165
162
 
166
163
  // only include the workflow node if main part file is delete
167
- if (that.#diffOnly && that.#mainDeleted) {
164
+ if (that.#delta && that.#mainDeleted) {
168
165
  that.desPkg.addMember(
169
- that.#root,
166
+ that.metadataDefinition.type,
170
167
  that.#fileName.shortName,
171
168
  )
172
169
  }
@@ -197,7 +194,10 @@ export class Combine {
197
194
  !that.metadataDefinition.packageTypeIsDirectory &&
198
195
  global.git.enabled
199
196
  ) {
200
- that.desPkg.addMember(that.#root, that.#fileName.shortName)
197
+ that.desPkg.addMember(
198
+ that.metadataDefinition.type,
199
+ that.#fileName.shortName,
200
+ )
201
201
  }
202
202
  deleteFile(that, that.#fileName.fullName)
203
203
  return 'deleted'
@@ -389,7 +389,7 @@ export class Combine {
389
389
  )
390
390
  }
391
391
 
392
- if (that.#diffOnly) {
392
+ if (that.#delta) {
393
393
  if (
394
394
  !that.#addedFiles
395
395
  .concat(that.#deletedFiles)
@@ -445,7 +445,7 @@ export class Combine {
445
445
  that.metadataDefinition.packageTypeIsDirectory
446
446
  ) {
447
447
  that.desPkg.addMember(
448
- that.#root,
448
+ that.metadataDefinition.type,
449
449
  fileObj.shortName.replace(`.${global.format}`, ''),
450
450
  )
451
451
  }
@@ -526,7 +526,7 @@ export class Combine {
526
526
  )
527
527
  } else if (that.metadataDefinition.packageTypeIsDirectory) {
528
528
  that.addPkg.addMember(
529
- that.#root,
529
+ that.metadataDefinition.type,
530
530
  fileObj.shortName.replace(`.${global.format}`, ''),
531
531
  )
532
532
  }
@@ -152,7 +152,7 @@ it('should correctly process the json object returned from the XML file', async
152
152
  name: 'PermissionSet',
153
153
  },
154
154
  {
155
- members: ['Test', 'Test.yaml'],
155
+ members: ['Test.yaml'],
156
156
  name: 'Workflow',
157
157
  },
158
158
  ],
@@ -182,10 +182,6 @@ it('should correctly process the json object returned from the XML file', async
182
182
  members: ['Test'],
183
183
  name: 'PermissionSet',
184
184
  },
185
- {
186
- members: ['Test'],
187
- name: 'Workflow',
188
- },
189
185
  ],
190
186
  version: '56.0',
191
187
  },