@ds-sfdc/sfparty 1.4.17 → 1.4.19
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/.github/dependabot.yml +11 -0
- package/package.json +1 -2
- package/src/lib/gitUtils.js +25 -4
- package/test/lib/git/lastCommit.spec.js +27 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
|
3
|
+
# Please see the documentation for all configuration options:
|
|
4
|
+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
|
5
|
+
|
|
6
|
+
version: 2
|
|
7
|
+
updates:
|
|
8
|
+
- package-ecosystem: "npm" # See documentation for possible values
|
|
9
|
+
directory: "/" # Location of package manifests
|
|
10
|
+
schedule:
|
|
11
|
+
interval: "weekly"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ds-sfdc/sfparty",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.19",
|
|
4
4
|
"description": "Salesforce metadata XML splitter for CI/CD",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
"main": "src/index.js",
|
|
14
14
|
"scripts": {
|
|
15
15
|
"test": "jest",
|
|
16
|
-
"_postinstall": "husky install",
|
|
17
16
|
"prepack": "pinst --disable",
|
|
18
17
|
"postpack": "pinst --enable"
|
|
19
18
|
},
|
package/src/lib/gitUtils.js
CHANGED
|
@@ -160,21 +160,42 @@ export function lastCommit({
|
|
|
160
160
|
try {
|
|
161
161
|
const folder = path.resolve(dir, '.sfdx', 'sfparty')
|
|
162
162
|
const filePath = path.resolve(folder, fileName)
|
|
163
|
-
let
|
|
163
|
+
let branchSpecificLastCommit
|
|
164
164
|
|
|
165
|
+
// Ensure the folder exists
|
|
165
166
|
fileUtils.createDirectory(folder)
|
|
167
|
+
|
|
166
168
|
if (existsSync(filePath)) {
|
|
167
169
|
const data = fileUtils.readFile(filePath)
|
|
168
|
-
|
|
169
|
-
|
|
170
|
+
|
|
171
|
+
// Determine the current branch name
|
|
172
|
+
const currentBranch = execSync(
|
|
173
|
+
`git rev-parse --abbrev-ref HEAD`,
|
|
174
|
+
{
|
|
175
|
+
cwd: dir,
|
|
176
|
+
encoding: 'utf-8',
|
|
177
|
+
},
|
|
178
|
+
).trim()
|
|
179
|
+
|
|
180
|
+
// Check if branch-specific last commit exists
|
|
181
|
+
if (
|
|
182
|
+
data.git.branches &&
|
|
183
|
+
data.git.branches[currentBranch] !== undefined
|
|
184
|
+
) {
|
|
185
|
+
branchSpecificLastCommit = data.git.branches[currentBranch]
|
|
186
|
+
} else {
|
|
187
|
+
// Fallback to top-level lastCommit if branch-specific commit doesn't exist
|
|
188
|
+
branchSpecificLastCommit = data.git.lastCommit
|
|
170
189
|
}
|
|
171
190
|
}
|
|
191
|
+
|
|
172
192
|
const latestCommit = execSync(`git log --format=format:%H -1`, {
|
|
173
193
|
cwd: dir,
|
|
174
194
|
encoding: 'utf-8',
|
|
175
195
|
})
|
|
196
|
+
|
|
176
197
|
resolve({
|
|
177
|
-
lastCommit:
|
|
198
|
+
lastCommit: branchSpecificLastCommit,
|
|
178
199
|
latestCommit: latestCommit,
|
|
179
200
|
})
|
|
180
201
|
} catch (error) {
|
|
@@ -134,3 +134,30 @@ test('should throw an error when execSync returns an error', async () => {
|
|
|
134
134
|
expect(e.message).toBe('execSync error')
|
|
135
135
|
}
|
|
136
136
|
})
|
|
137
|
+
|
|
138
|
+
// Mock execSync to simulate branch detection
|
|
139
|
+
jest.mock('child_process', () => ({
|
|
140
|
+
...jest.requireActual('child_process'),
|
|
141
|
+
execSync: jest.fn((command) => {
|
|
142
|
+
if (command === 'git rev-parse --abbrev-ref HEAD') {
|
|
143
|
+
return 'currentBranch' // Simulate current branch name
|
|
144
|
+
}
|
|
145
|
+
return 'testCommit' // Simulate latest commit hash
|
|
146
|
+
}),
|
|
147
|
+
}))
|
|
148
|
+
|
|
149
|
+
test('should throw an error when execSync returns an error', async () => {
|
|
150
|
+
jest.spyOn(child_process, 'execSync').mockImplementationOnce(() => {
|
|
151
|
+
throw new Error('execSync error')
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
await expect(
|
|
155
|
+
lastCommit({
|
|
156
|
+
dir: '/test',
|
|
157
|
+
fileUtils,
|
|
158
|
+
fs,
|
|
159
|
+
existsSync: fs.existsSync,
|
|
160
|
+
execSync: child_process.execSync,
|
|
161
|
+
}),
|
|
162
|
+
).rejects.toThrow('execSync error')
|
|
163
|
+
})
|