@ds-sfdc/sfparty 1.3.6 → 1.3.7
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/lib/packageUtil.js
CHANGED
|
@@ -25,7 +25,6 @@ export class Package {
|
|
|
25
25
|
processJSON(that, json, fileUtils)
|
|
26
26
|
resolve('existing')
|
|
27
27
|
} catch (error) {
|
|
28
|
-
console.error(error)
|
|
29
28
|
reject(error)
|
|
30
29
|
}
|
|
31
30
|
})
|
|
@@ -55,6 +54,20 @@ export class Package {
|
|
|
55
54
|
}
|
|
56
55
|
that.packageJSON = json
|
|
57
56
|
if (json.Package.types !== undefined) transformJSON(json.Package.types)
|
|
57
|
+
cleanPackage(that)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function cleanPackage(that) {
|
|
61
|
+
if (that.packageJSON === undefined) throw new Error('getPackageXML must be called before adding members')
|
|
62
|
+
if (that.packageJSON.Package == undefined) throw new Error('Package initialization failed')
|
|
63
|
+
if (that.packageJSON.Package.types === undefined) return 'No types found'
|
|
64
|
+
|
|
65
|
+
const typeArray = Object.values(global.metaTypes).map(metaType => metaType.definition.root);
|
|
66
|
+
that.packageJSON.Package.types.forEach(typeItem => {
|
|
67
|
+
if (typeArray.includes(typeItem.name)) {
|
|
68
|
+
typeItem.members = typeItem.members.filter(member => !member.endsWith(`.${global.format}`))
|
|
69
|
+
}
|
|
70
|
+
})
|
|
58
71
|
}
|
|
59
72
|
}
|
|
60
73
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import axios from 'axios'
|
|
2
2
|
import { spawnSync } from 'child_process'
|
|
3
3
|
import clc from 'cli-color'
|
|
4
|
-
import { checkVersion } from '
|
|
4
|
+
import { checkVersion } from '../../src/lib/checkVersion.js'
|
|
5
5
|
|
|
6
6
|
global.icons = {
|
|
7
7
|
"success": clc.greenBright('✔'),
|
|
@@ -1,5 +1,39 @@
|
|
|
1
|
+
|
|
1
2
|
import * as packageDefinition from '../../../src/meta/Package.js'
|
|
2
3
|
import { Package } from '../../../src/lib/packageUtil.js'
|
|
4
|
+
import * as labelDefinition from '../../../src/meta/CustomLabels.js'
|
|
5
|
+
import * as profileDefinition from '../../../src/meta/Profiles.js'
|
|
6
|
+
import * as permsetDefinition from '../../../src/meta/PermissionSets.js'
|
|
7
|
+
import * as workflowDefinition from '../../../src/meta/Workflows.js'
|
|
8
|
+
|
|
9
|
+
global.__basedir = '.'
|
|
10
|
+
|
|
11
|
+
global.metaTypes = {
|
|
12
|
+
label: {
|
|
13
|
+
type: labelDefinition.metadataDefinition.filetype,
|
|
14
|
+
definition: labelDefinition.metadataDefinition,
|
|
15
|
+
add: { files: [], directories: [] },
|
|
16
|
+
remove: { files: [], directories: [] },
|
|
17
|
+
},
|
|
18
|
+
profile: {
|
|
19
|
+
type: profileDefinition.metadataDefinition.filetype,
|
|
20
|
+
definition: profileDefinition.metadataDefinition,
|
|
21
|
+
add: { files: [], directories: [] },
|
|
22
|
+
remove: { files: [], directories: [] },
|
|
23
|
+
},
|
|
24
|
+
permset: {
|
|
25
|
+
type: permsetDefinition.metadataDefinition.filetype,
|
|
26
|
+
definition: permsetDefinition.metadataDefinition,
|
|
27
|
+
add: { files: [], directories: [] },
|
|
28
|
+
remove: { files: [], directories: [] },
|
|
29
|
+
},
|
|
30
|
+
workflow: {
|
|
31
|
+
type: workflowDefinition.metadataDefinition.filetype,
|
|
32
|
+
definition: workflowDefinition.metadataDefinition,
|
|
33
|
+
add: { files: [], directories: [] },
|
|
34
|
+
remove: { files: [], directories: [] },
|
|
35
|
+
},
|
|
36
|
+
}
|
|
3
37
|
|
|
4
38
|
let pkg;
|
|
5
39
|
const fileUtils = {
|
|
@@ -9,7 +43,8 @@ const fileUtils = {
|
|
|
9
43
|
beforeEach(() => {
|
|
10
44
|
pkg = new Package('xmlPath');
|
|
11
45
|
});
|
|
12
|
-
|
|
46
|
+
|
|
47
|
+
|
|
13
48
|
afterEach(() => {
|
|
14
49
|
jest.clearAllMocks();
|
|
15
50
|
});
|
|
@@ -55,3 +90,79 @@ it('should throw an error if error occurs during processing', async () => {
|
|
|
55
90
|
fileUtils.readFile.mockRejectedValue(new Error('Error'));
|
|
56
91
|
await expect(pkg.getPackageXML(fileUtils)).rejects.toThrowError('Error');
|
|
57
92
|
});
|
|
93
|
+
|
|
94
|
+
it('should catch errors and reject the promise', async () => {
|
|
95
|
+
fileUtils.fileExists.mockReturnValue(true);
|
|
96
|
+
fileUtils.readFile.mockRejectedValue(new Error('Test Error'));
|
|
97
|
+
global.git = { append: true }
|
|
98
|
+
try {
|
|
99
|
+
await pkg.getPackageXML(fileUtils);
|
|
100
|
+
} catch (error) {
|
|
101
|
+
expect(error.message).toEqual('Test Error');
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('should default to an empty package if the read file is empty', async () => {
|
|
106
|
+
fileUtils.fileExists.mockReturnValue(true);
|
|
107
|
+
fileUtils.readFile.mockResolvedValue('');
|
|
108
|
+
global.git = { append: true }
|
|
109
|
+
const result = await pkg.getPackageXML(fileUtils);
|
|
110
|
+
expect(result).toBe('existing');
|
|
111
|
+
expect(pkg.packageJSON).toEqual(packageDefinition.metadataDefinition.emptyPackage);
|
|
112
|
+
expect(fileUtils.fileExists).toHaveBeenCalled();
|
|
113
|
+
expect(fileUtils.readFile).toHaveBeenCalled();
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('should throw an error if fileUtils.readFile() returns a rejected promise', async () => {
|
|
117
|
+
fileUtils.fileExists.mockReturnValue(true);
|
|
118
|
+
fileUtils.readFile.mockRejectedValue(new Error('Test Error'));
|
|
119
|
+
global.git = { append: true }
|
|
120
|
+
await expect(pkg.getPackageXML(fileUtils)).rejects.toThrowError('Test Error');
|
|
121
|
+
expect(fileUtils.fileExists).toHaveBeenCalled();
|
|
122
|
+
expect(fileUtils.readFile).toHaveBeenCalled();
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it('should correctly process the json object returned from the XML file', async () => {
|
|
126
|
+
fileUtils.fileExists.mockReturnValue(true);
|
|
127
|
+
fileUtils.readFile.mockResolvedValue({
|
|
128
|
+
"Package": {
|
|
129
|
+
"types": [{
|
|
130
|
+
"members": ["Test", "Test.yaml"],
|
|
131
|
+
"name": "CustomLabels"
|
|
132
|
+
}, {
|
|
133
|
+
"members": ["Test", "Test.yaml"],
|
|
134
|
+
"name": "Profile"
|
|
135
|
+
}, {
|
|
136
|
+
"members": ["Test", "Test.yaml"],
|
|
137
|
+
"name": "PermissionSet"
|
|
138
|
+
}, {
|
|
139
|
+
"members": ["Test", "Test.yaml"],
|
|
140
|
+
"name": "Workflow"
|
|
141
|
+
}],
|
|
142
|
+
"version": "56.0"
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
global.git = { append: true }
|
|
146
|
+
const result = await pkg.getPackageXML(fileUtils);
|
|
147
|
+
expect(result).toBe('existing');
|
|
148
|
+
expect(fileUtils.fileExists).toHaveBeenCalled();
|
|
149
|
+
expect(fileUtils.readFile).toHaveBeenCalled();
|
|
150
|
+
expect(pkg.packageJSON).toEqual({
|
|
151
|
+
"Package": {
|
|
152
|
+
"types": [{
|
|
153
|
+
"members": ["Test", "Test.yaml"],
|
|
154
|
+
"name": "CustomLabels"
|
|
155
|
+
}, {
|
|
156
|
+
"members": ["Test", "Test.yaml"],
|
|
157
|
+
"name": "Profile"
|
|
158
|
+
}, {
|
|
159
|
+
"members": ["Test", "Test.yaml"],
|
|
160
|
+
"name": "PermissionSet"
|
|
161
|
+
}, {
|
|
162
|
+
"members": ["Test", "Test.yaml"],
|
|
163
|
+
"name": "Workflow"
|
|
164
|
+
}],
|
|
165
|
+
"version": "56.0"
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
});
|
|
File without changes
|