Skip to content

Commit 66a099b

Browse files
committed
chore: several improvements
1 parent 29efe99 commit 66a099b

File tree

3 files changed

+50
-5
lines changed

3 files changed

+50
-5
lines changed

src/buddy.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-console */
12
import type {
23
BuddyBotConfig,
34
DashboardData,
@@ -126,6 +127,12 @@ export class Buddy {
126127

127128
// Determine if we have workflow permissions (BUDDY_BOT_TOKEN has full permissions)
128129
const hasWorkflowPermissions = !!process.env.BUDDY_BOT_TOKEN
130+
if (process.env.BUDDY_BOT_TOKEN) {
131+
console.log('✅ BUDDY_BOT_TOKEN detected - workflow permissions enabled')
132+
}
133+
else {
134+
console.log('⚠️ BUDDY_BOT_TOKEN not found - workflow permissions disabled')
135+
}
129136

130137
// Initialize GitHub provider
131138
const gitProvider = new GitHubProvider(

src/git/github-provider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class GitHubProvider implements GitProvider {
5454
if (workflowFiles.length > 0 && !this.hasWorkflowPermissions) {
5555
console.warn(`⚠️ Detected ${workflowFiles.length} workflow file(s). These require elevated permissions.`)
5656
console.warn(`⚠️ Workflow files: ${workflowFiles.map(f => f.path).join(', ')}`)
57-
console.warn(`ℹ️ Workflow files will be skipped in this commit. You need to set BUDDY_BOT_TOKEN (with workflow permissions) in the repository settings.`)
57+
console.warn(`ℹ️ Workflow files will be skipped in this commit. BUDDY_BOT_TOKEN not detected or lacks workflow permissions.`)
5858

5959
// If we have non-workflow files, commit just those
6060
if (nonWorkflowFiles.length > 0) {
@@ -63,7 +63,7 @@ export class GitHubProvider implements GitProvider {
6363
}
6464
else {
6565
console.warn(`⚠️ All files are workflow files. No files will be committed in this PR.`)
66-
console.warn(`💡 To update workflow files, you need to set BUDDY_BOT_TOKEN (with workflow permissions) in the repository settings.`)
66+
console.warn(`💡 To update workflow files, ensure BUDDY_BOT_TOKEN is set with workflow:write permissions.`)
6767
return // Exit early if no non-workflow files to commit
6868
}
6969
}

src/pr/pr-generator.ts

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,44 @@ export class PullRequestGenerator {
6666
// Add update type labels
6767
if (group.updateType === 'major') {
6868
labels.push('major')
69-
} else if (group.updateType === 'minor') {
69+
}
70+
else if (group.updateType === 'minor') {
7071
labels.push('minor')
71-
} else if (group.updateType === 'patch') {
72+
}
73+
else if (group.updateType === 'patch') {
7274
labels.push('patch')
7375
}
7476

77+
// Add package type labels based on what types of packages are being updated
78+
const npmCount = group.updates.filter(u =>
79+
u.file === 'package.json' || u.file.endsWith('/package.json') || u.file.endsWith('\\package.json'),
80+
).length
81+
82+
const composerCount = group.updates.filter(u =>
83+
u.file.endsWith('composer.json') || u.file.endsWith('composer.lock'),
84+
).length
85+
86+
const systemCount = group.updates.filter(u =>
87+
(u.file.includes('.yaml') || u.file.includes('.yml')) && !u.file.includes('.github/workflows/'),
88+
).length
89+
90+
const actionsCount = group.updates.filter(u =>
91+
u.file.includes('.github/workflows/'),
92+
).length
93+
94+
// Add package type labels
95+
if (npmCount > 0)
96+
labels.push('npm')
97+
if (composerCount > 0)
98+
labels.push('composer')
99+
if (systemCount > 0)
100+
labels.push('system')
101+
if (actionsCount > 0)
102+
labels.push('github-actions')
103+
75104
// For single package updates, add the specific package name as a label
76105
if (group.updates.length === 1) {
77-
const update = group.updates[0]
106+
// const update = group.updates[0]
78107
labels.push(group.title) // This will be like "chore(deps): update dependency stripe to 18.4.0"
79108
}
80109

@@ -118,9 +147,18 @@ export class PullRequestGenerator {
118147
dependencyType: u.dependencyType,
119148
currentVersion: u.currentVersion,
120149
newVersion: u.newVersion,
150+
updateType: u.updateType,
121151
})),
122152
})
123153

154+
// Early validation - warn about empty updates
155+
if (group.updates.length === 0) {
156+
this.log('⚠️ WARNING: No updates in group - this will result in sparse PR body', {
157+
groupName: group.name,
158+
groupTitle: group.title,
159+
})
160+
}
161+
124162
// Count different types of updates
125163
const packageJsonCount = group.updates.filter(u =>
126164
u.file === 'package.json' || u.file.endsWith('/package.json') || u.file.endsWith('\\package.json'),

0 commit comments

Comments
 (0)