Skip to content

Commit 074ba77

Browse files
committed
chore: wip
1 parent d188778 commit 074ba77

File tree

5 files changed

+37
-26
lines changed

5 files changed

+37
-26
lines changed

src/buddy.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ export class Buddy {
199199
return new Promise((resolve, reject) => {
200200
const child = spawn(command, args, { stdio: 'pipe' })
201201
child.on('close', (code) => {
202-
if (code === 0) resolve()
202+
if (code === 0)
203+
resolve()
203204
else reject(new Error(`Git command failed with code ${code}`))
204205
})
205206
child.on('error', reject)
@@ -210,6 +211,7 @@ export class Buddy {
210211
await runGitCommand('git', ['checkout', 'main'])
211212
await runGitCommand('git', ['reset', '--hard', 'HEAD'])
212213
await runGitCommand('git', ['clean', '-fd'])
214+
// eslint-disable-next-line no-console
213215
console.log(`🧹 Reset to clean main state before generating updates for ${group.name}`)
214216
}
215217
catch (error) {

src/git/github-provider.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ export class GitHubProvider implements GitProvider {
5959
if (nonWorkflowFiles.length > 0) {
6060
console.log(`📝 Committing ${nonWorkflowFiles.length} non-workflow files...`)
6161
files = nonWorkflowFiles
62-
} else {
62+
}
63+
else {
6364
console.warn(`⚠️ All files are workflow files. No files will be committed in this PR.`)
6465
console.warn(`💡 To update workflow files, consider using a GitHub App with appropriate permissions.`)
6566
return // Exit early if no non-workflow files to commit
@@ -162,7 +163,8 @@ export class GitHubProvider implements GitProvider {
162163
if (nonWorkflowFiles.length > 0) {
163164
console.log(`📝 Committing ${nonWorkflowFiles.length} non-workflow files...`)
164165
files = nonWorkflowFiles
165-
} else {
166+
}
167+
else {
166168
console.warn(`⚠️ All files are workflow files. No files will be committed in this PR.`)
167169
console.warn(`💡 To update workflow files, consider using a GitHub App with appropriate permissions.`)
168170
return // Exit early if no non-workflow files to commit

src/pr/pr-generator.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ export class PullRequestGenerator {
206206
const sourceUrl = this.getComposerSourceUrl(packageInfo.repository.url, update.name)
207207
// Format: [packageName](repoUrl) ([source](sourceUrl)) - matching npm format
208208
packageCell = `[${update.name}](${sourceUrl}) ([source](${sourceUrl}))`
209-
} else {
209+
}
210+
else {
210211
// Fallback to Packagist page only
211212
packageCell = `[${update.name}](https://packagist.org/packages/${encodeURIComponent(update.name)})`
212213
}
@@ -259,8 +260,6 @@ export class PullRequestGenerator {
259260
body += `\n`
260261
}
261262

262-
263-
264263
// GitHub Actions table (simplified, without badges, deduplicated)
265264
if (uniqueGithubActionsUpdates.length > 0) {
266265
body += `### GitHub Actions\n\n`

src/registry/registry-client.ts

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,8 @@ export class RegistryClient {
630630
if (showData.versions) {
631631
availableVersions = showData.versions // This is already an array of version strings
632632
}
633-
} catch (error) {
633+
}
634+
catch (error) {
634635
console.warn(`Failed to get available versions for ${pkg.name}, using latest only:`, error)
635636
availableVersions = [latestVersion]
636637
}
@@ -676,7 +677,7 @@ export class RegistryClient {
676677
/**
677678
* Find the best patch, minor, and major updates for a package
678679
*/
679-
private async findBestUpdates(currentVersion: string, availableVersions: string[], constraint: string): Promise<{ version: string, type: 'patch' | 'minor' | 'major' }[]> {
680+
private async findBestUpdates(currentVersion: string, availableVersions: string[], _constraint: string): Promise<{ version: string, type: 'patch' | 'minor' | 'major' }[]> {
680681
const { getUpdateType } = await import('../utils/helpers')
681682
const candidates: { version: string, type: 'patch' | 'minor' | 'major' }[] = []
682683

@@ -714,11 +715,13 @@ export class RegistryClient {
714715
if (!bestPatch || this.compareVersions(version, bestPatch) > 0) {
715716
bestPatch = version
716717
}
717-
} else if (updateType === 'minor' && versionParts.major === currentParts.major) {
718+
}
719+
else if (updateType === 'minor' && versionParts.major === currentParts.major) {
718720
if (!bestMinor || this.compareVersions(version, bestMinor) > 0) {
719721
bestMinor = version
720722
}
721-
} else if (updateType === 'major') {
723+
}
724+
else if (updateType === 'major') {
722725
if (!bestMajor || this.compareVersions(version, bestMajor) > 0) {
723726
bestMajor = version
724727
}
@@ -745,16 +748,16 @@ export class RegistryClient {
745748
private parseVersion(version: string): { major: number, minor: number, patch: number } | null {
746749
// Remove 'v' prefix and any pre-release identifiers
747750
const cleanVersion = version.replace(/^v/, '').split('-')[0].split('+')[0]
748-
const parts = cleanVersion.split('.').map(p => parseInt(p, 10))
751+
const parts = cleanVersion.split('.').map(p => Number.parseInt(p, 10))
749752

750-
if (parts.length < 2 || parts.some(p => isNaN(p))) {
753+
if (parts.length < 2 || parts.some(p => Number.isNaN(p))) {
751754
return null
752755
}
753756

754757
return {
755758
major: parts[0] || 0,
756759
minor: parts[1] || 0,
757-
patch: parts[2] || 0
760+
patch: parts[2] || 0,
758761
}
759762
}
760763

@@ -766,10 +769,13 @@ export class RegistryClient {
766769
const parseA = this.parseVersion(a)
767770
const parseB = this.parseVersion(b)
768771

769-
if (!parseA || !parseB) return 0
772+
if (!parseA || !parseB)
773+
return 0
770774

771-
if (parseA.major !== parseB.major) return parseA.major - parseB.major
772-
if (parseA.minor !== parseB.minor) return parseA.minor - parseB.minor
775+
if (parseA.major !== parseB.major)
776+
return parseA.major - parseB.major
777+
if (parseA.minor !== parseB.minor)
778+
return parseA.minor - parseB.minor
773779
return parseA.patch - parseB.patch
774780
}
775781

@@ -972,11 +978,13 @@ export class RegistryClient {
972978
if (!bestPatch || this.compareVersions(version, bestPatch) > 0) {
973979
bestPatch = version
974980
}
975-
} else if (updateType === 'minor' && versionParts.major === currentParts.major) {
981+
}
982+
else if (updateType === 'minor' && versionParts.major === currentParts.major) {
976983
if (!bestMinor || this.compareVersions(version, bestMinor) > 0) {
977984
bestMinor = version
978985
}
979-
} else if (updateType === 'major') {
986+
}
987+
else if (updateType === 'major') {
980988
if (!bestMajor || this.compareVersions(version, bestMajor) > 0) {
981989
bestMajor = version
982990
}

test/composer-non-major-pr.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ describe('Composer Non-Major PR', () => {
177177
metadata: {
178178
name: 'monolog/monolog',
179179
repository: 'https://github.com/Seldaek/monolog',
180-
description: 'Sends your logs to files, sockets, inboxes, databases and various web services'
181-
}
180+
description: 'Sends your logs to files, sockets, inboxes, databases and various web services',
181+
},
182182
},
183183
{
184184
name: 'monolog/monolog', // Duplicate package
@@ -190,8 +190,8 @@ describe('Composer Non-Major PR', () => {
190190
metadata: {
191191
name: 'monolog/monolog',
192192
repository: 'https://github.com/Seldaek/monolog',
193-
description: 'Sends your logs to files, sockets, inboxes, databases and various web services'
194-
}
193+
description: 'Sends your logs to files, sockets, inboxes, databases and various web services',
194+
},
195195
},
196196
{
197197
name: 'phpunit/phpunit',
@@ -237,8 +237,8 @@ describe('Composer Non-Major PR', () => {
237237
metadata: {
238238
name: 'monolog/monolog',
239239
repository: 'https://github.com/Seldaek/monolog',
240-
description: 'Sends your logs to files, sockets, inboxes, databases and various web services'
241-
}
240+
description: 'Sends your logs to files, sockets, inboxes, databases and various web services',
241+
},
242242
},
243243
],
244244
updateType: 'minor',
@@ -250,11 +250,11 @@ describe('Composer Non-Major PR', () => {
250250

251251
// Should format like npm: [packageName](repoUrl) ([source](sourceUrl))
252252
expect(prBody).toContain('[monolog/monolog](https://github.com/Seldaek/monolog/tree/master) ([source](https://github.com/Seldaek/monolog/tree/master))')
253-
253+
254254
// Should have the same columns as npm dependencies
255255
expect(prBody).toContain('| Package | Change | Age | Adoption | Passing | Confidence |')
256256
expect(prBody).toContain('|---|---|---|---|---|---|')
257-
257+
258258
// Should have confidence badges
259259
expect(prBody).toContain('[![age](https://developer.mend.io/api/mc/badges/age/packagist/')
260260
expect(prBody).toContain('[![adoption](https://developer.mend.io/api/mc/badges/adoption/packagist/')

0 commit comments

Comments
 (0)