@ds-sfdc/sfparty 1.3.7 → 1.3.9
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 +9 -0
- package/package.json +3 -1
- package/pre-commit +4 -0
- package/src/index.js +752 -572
- package/src/lib/checkVersion.js +84 -62
- package/src/lib/fileUtils.js +175 -156
- package/src/lib/gitUtils.js +140 -112
- package/src/lib/packageUtil.js +232 -193
- package/src/lib/pkgObj.cjs +1 -0
- package/src/meta/CustomLabels.js +27 -24
- package/src/meta/Package.js +22 -21
- package/src/meta/PermissionSets.js +75 -66
- package/src/meta/Profiles.js +84 -81
- package/src/meta/Workflows.js +125 -55
- package/src/meta/yargs.js +98 -93
- package/src/party/combine.js +262 -97
- package/src/party/split.js +391 -314
- package/test/lib/package/getPackageXML.spec.js +69 -66
package/src/lib/gitUtils.js
CHANGED
|
@@ -5,133 +5,161 @@ import { existsSync } from 'fs'
|
|
|
5
5
|
import * as fileUtils from './fileUtils.js'
|
|
6
6
|
|
|
7
7
|
const defaultDefinition = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
git: {
|
|
9
|
+
lastCommit: undefined,
|
|
10
|
+
latestCommit: undefined,
|
|
11
|
+
},
|
|
12
|
+
local: {
|
|
13
|
+
lastDate: undefined,
|
|
14
|
+
},
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
const status = {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
18
|
+
A: {
|
|
19
|
+
type: 'add',
|
|
20
|
+
action: 'add',
|
|
21
|
+
},
|
|
22
|
+
C: {
|
|
23
|
+
type: 'copy',
|
|
24
|
+
action: 'add',
|
|
25
|
+
},
|
|
26
|
+
D: {
|
|
27
|
+
type: 'delete',
|
|
28
|
+
action: 'delete',
|
|
29
|
+
},
|
|
30
|
+
M: {
|
|
31
|
+
type: 'modify',
|
|
32
|
+
action: 'add',
|
|
33
|
+
},
|
|
34
|
+
R: {
|
|
35
|
+
type: 'rename',
|
|
36
|
+
action: 'add',
|
|
37
|
+
},
|
|
38
|
+
T: {
|
|
39
|
+
type: 'type change',
|
|
40
|
+
action: 'add',
|
|
41
|
+
},
|
|
42
|
+
U: {
|
|
43
|
+
type: 'unmerged',
|
|
44
|
+
action: 'ignore',
|
|
45
|
+
},
|
|
46
|
+
X: {
|
|
47
|
+
type: 'unknown',
|
|
48
|
+
action: 'ignore',
|
|
49
|
+
},
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
export function diff(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
export function diff(
|
|
53
|
+
dir,
|
|
54
|
+
gitRef = 'HEAD',
|
|
55
|
+
existsSyncStub = existsSync,
|
|
56
|
+
execSyncStub = execSync,
|
|
57
|
+
) {
|
|
58
|
+
return new Promise((resolve, reject) => {
|
|
59
|
+
if (!existsSyncStub(dir) || !existsSyncStub(path.join(dir, '.git'))) {
|
|
60
|
+
reject(new Error(`The directory "${dir}" is not a git repository`))
|
|
61
|
+
}
|
|
57
62
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
let data = ''
|
|
64
|
+
try {
|
|
65
|
+
data = execSyncStub(
|
|
66
|
+
`git diff --name-status --oneline --relative ${gitRef} -- *-party/*`,
|
|
67
|
+
{ cwd: dir, maxBuffer: 1024 * 1024 * 10 },
|
|
68
|
+
).toString()
|
|
69
|
+
} catch (error) {
|
|
70
|
+
reject(error)
|
|
71
|
+
}
|
|
64
72
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
73
|
+
const gitData = data.toString().split(os.EOL)
|
|
74
|
+
const files = gitData.reduce((acc, gitRow) => {
|
|
75
|
+
if (gitRow.indexOf('\t') > 0) {
|
|
76
|
+
const file = gitRow.split('\t')
|
|
77
|
+
if (file.slice(-1) !== '') {
|
|
78
|
+
const statusType =
|
|
79
|
+
status[
|
|
80
|
+
file[0] === file.slice(-1)
|
|
81
|
+
? 'A'
|
|
82
|
+
: Array.from(file[0])[0]
|
|
83
|
+
]
|
|
84
|
+
acc.push({
|
|
85
|
+
type: statusType.type,
|
|
86
|
+
path: file.slice(-1)[0],
|
|
87
|
+
action: statusType.action,
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return acc
|
|
92
|
+
}, [])
|
|
93
|
+
resolve(files)
|
|
94
|
+
})
|
|
82
95
|
}
|
|
83
96
|
|
|
84
97
|
export function log(dir, gitRef, execSyncStub = execSync) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
98
|
+
try {
|
|
99
|
+
const gitLog = execSyncStub(`git log --format=format:%H ${gitRef}`, {
|
|
100
|
+
cwd: dir,
|
|
101
|
+
encoding: 'utf-8',
|
|
102
|
+
})
|
|
103
|
+
const commits = gitLog.split(os.EOL).filter((commit) => commit)
|
|
104
|
+
return commits
|
|
105
|
+
} catch (error) {
|
|
106
|
+
if (error.message.indexOf('ENOENT') > -1) {
|
|
107
|
+
error.message = 'git not installed or no entry found in path'
|
|
108
|
+
}
|
|
109
|
+
throw error
|
|
110
|
+
}
|
|
95
111
|
}
|
|
96
112
|
|
|
97
|
-
export function lastCommit(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
113
|
+
export function lastCommit(
|
|
114
|
+
dir,
|
|
115
|
+
fileName = 'index.yaml',
|
|
116
|
+
existsSyncStub = existsSync,
|
|
117
|
+
execSyncStub = execSync,
|
|
118
|
+
fileUtilsStub = fileUtils,
|
|
119
|
+
) {
|
|
120
|
+
try {
|
|
121
|
+
const folder = path.resolve(dir, '.sfdx', 'sfparty')
|
|
122
|
+
const filePath = path.resolve(folder, fileName)
|
|
123
|
+
let lastCommit = undefined
|
|
102
124
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
125
|
+
fileUtilsStub.createDirectory(folder)
|
|
126
|
+
if (existsSyncStub(filePath)) {
|
|
127
|
+
const data = fileUtilsStub.readFile(filePath)
|
|
128
|
+
if (data.git.lastCommit !== undefined) {
|
|
129
|
+
lastCommit = data.git.lastCommit
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
const latestCommit = execSyncStub(`git log --format=format:%H -1`, {
|
|
133
|
+
cwd: dir,
|
|
134
|
+
encoding: 'utf-8',
|
|
135
|
+
})
|
|
136
|
+
return {
|
|
137
|
+
lastCommit: lastCommit,
|
|
138
|
+
latestCommit: latestCommit,
|
|
139
|
+
}
|
|
140
|
+
} catch (error) {
|
|
141
|
+
throw new Error(error)
|
|
142
|
+
}
|
|
118
143
|
}
|
|
119
144
|
|
|
120
145
|
export function updateLastCommit(dir, latest, fileUtilsStub = fileUtils) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
146
|
+
if (typeof latest !== 'string' && typeof latest !== 'undefined')
|
|
147
|
+
throw new Error(
|
|
148
|
+
`updateLastCommit received a ${typeof latest} instead of string`,
|
|
149
|
+
)
|
|
150
|
+
if (latest !== undefined) {
|
|
151
|
+
const folder = path.join(dir, '.sfdx', 'sfparty')
|
|
152
|
+
const fileName = path.join(folder, 'index.yaml')
|
|
153
|
+
let data = undefined
|
|
154
|
+
if (fileUtilsStub.fileExists(fileName)) {
|
|
155
|
+
data = fileUtilsStub.readFile(fileName)
|
|
156
|
+
}
|
|
129
157
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
158
|
+
if (data === undefined) {
|
|
159
|
+
data = defaultDefinition
|
|
160
|
+
}
|
|
133
161
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
162
|
+
data.git.lastCommit = latest
|
|
163
|
+
fileUtilsStub.saveFile(data, fileName)
|
|
164
|
+
}
|
|
165
|
+
}
|